0

I have a ffmpeg command that plays several videos from a folder to a live stream, but I would also like to add text overlays over it. The problem is that I used complex filter to concatenate the videos, and -vf to drawtext, but ffmpeg says I can't use complex filters and -vf in the same time. I can't use another method for concatenation, so how should I do ? (I don't mind about using several commands, as long as everything is done live and can be streamed directly)

By the way, here's an example command I use :

ffmpeg \
-i video1.mp4 -i video2.mp4
-filter_complex "[0:v:0] [0:a:0] [0:v:1] [0:a:1] concat=n=2:v=1:a=1 [v] [a]" \
-vf "drawtext=text='SOME TEXT':x=(w-text_w):y=(h-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white" \
-map "[v]" -map "[a]" -deinterlace \
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
-acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \
-f flv "$YOUTUBE_URL/$KEY"

The problem only comes from the -vf because it works well without it.

2

Just chain the drawtext, at the end.

ffmpeg \
-i video1.mp4 -i video2.mp4
-filter_complex "[0:v:0] [0:a:0] [0:v:1] [0:a:1] concat=n=2:v=1:a=1 [v][a];
[v]drawtext=text='SOME TEXT':x=(w-text_w):y=(h-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white[v]" \
-map "[v]" -map "[a]" -deinterlace \
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
-acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \
-f flv "$YOUTUBE_URL/$KEY"
  • Ah ok I tried just appending the drawtext and it didn't work, but I didn't know the [v] before and after were needed. If I want to draw multiple texts, do I have to seperate them with [v];[v] or can I just seperate them with a coma? – paulolol Oct 23 '17 at 14:37
  • 1
    If a filter consumes the output of the immediately prior filter, then just a comma will suffice. If a filter's output is consumed by another filter afterwards, then the output need not be labelled. In the case here, concat spits out two outputs, and the drawtext only wants the video, so the chain is broken. A semi-colon has to be placed after the concat, and the drawtext filter input should be explicitly labelled, in this case [v]. – Gyan Oct 23 '17 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.