Search code examples
avconvdrawtext

Avconv and "Unable to find a suitable output format" error


Hi I want to add some text on a .mp4.

I'm trying this :

shell_exec("avconv -i input.mp4 drawtext=\"fontfile=OpenSans-Italic.ttf: text='Test Text'\" output.mp4").

But I get

Unable to find a suitable output format for 'drawtext=fontfile=OpenSans-Italic.ttf: text='Test Text'' drawtext=fontfile=OpenSans-Italic.ttf: text='Test Text': Invalid argument

Any idea of what's going on ?


Solution

  • There is mistake with your argument drawtext. It is a filter but you need -vf before it so libav can understand what it is. Overall your command should be:

    shell_exec("avconv -i input.mp4 -vf drawtext=\"fontfile=OpenSans-Italic.ttf: text='Test Text'\" output.mp4")
    

    This looks like php so I would also suggest you to check:

    • Read/write permissions,
    • Path of OpenSans-Italic.ttf file,
    • Execution path vs file path
    • Whether libav was compiled with --enable-libfreetype option (which is required for drawtext filter)

    Source: https://libav.org/documentation/libavfilter.html#drawtext