Search code examples
androidffmpegoverlaydrawtext

FFMPEG, command with Overlay and Drawtext on video


I have 2 commands, one for overlay(work alone), one for add text (work alone), i want this 2 commands in one.

ffmpeg -i myvideo.mp4 -i image.png -filter_complex [0:v][1:v]overlay=5:5,drawtext=fontfile=:text=mytext:[email protected]:fontsize=30:x=30:y=200[v] -map [output] output.mp4

This command generate empty file without error.


Solution

  • Your -map option is using a label that does not reference anything.

    You should be getting this error:

    Output with label 'output' does not exist in any defined filter graph, or was already used elsewhere.
    

    The -filter_complex output and the -map option should use the same label. It can be almost any arbitrary name as long as they match. Also, your fontfile is missing the font path. You may have to quote your text string, but you're using Android and it is weird with quoting. Lastly, you should stream copy the audio.

    Use this: both filter output and -map are using [v]

    ffmpeg -i myvideo.mp4 -i image.png -filter_complex [0:v][1:v]overlay=5:5,drawtext=text=mytext:[email protected]:fontsize=30:x=30:y=200[v] -map [v] -map 0:a -c:a copy output.mp4
    

    or this: both filter output and -map are using [output]

    ffmpeg -i myvideo.mp4 -i image.png -filter_complex [0:v][1:v]overlay=5:5,drawtext=text=mytext:[email protected]:fontsize=30:x=30:y=200[output] -map [output] -map 0:a -c:a copy output.mp4
    

    or this: use the default stream selection

    ffmpeg -i myvideo.mp4 -i image.png -filter_complex [0:v][1:v]overlay=5:5,drawtext=text=mytext:[email protected]:fontsize=30:x=30:y=200 -c:a copy output.mp4