Answers.Body: <p>Just chain the drawtext, at the end.</p>
  
  <pre><code>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"
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-23T14:37:46.457Z
Answers.Text: 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?
Answers.UserDisplayName: Cyxo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-23T14:50:54.173Z
Answers.Text: 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]`.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-23T14:24:05.623Z
Answers.LastActivityDate: 2017-10-23T14:24:05.623Z
Answers.UserDisplayName: Gyan
Body: <p>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)</p>
  
  <p>By the way, here's an example command I use :</p>
  
  <pre><code>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"
  </code></pre>
  
  <p>The problem only comes from the -vf because it works well without it.</p>
  
Tags: <ffmpeg>
Title: FFMPEG - Use drawtext and complex filters
UserDisplayName: Cyxo
ThreadText: # FFMPEG - Use drawtext and complex filters
  
  (Asked by: username_0 on 2017-10-23)
  
  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.
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-10-23. Score: 3 | Accepted answer
  
  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"
  
  ```
  
  > **Comments:**
  > **username_0**: 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?  
  > **username_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]`.  
  
  ---
  
  