Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/h8joa.jpg" alt="6 video overlay with drawtext"></p> <h3>overlay</h3> <pre><code>ffmpeg -i input0 -i input1 -i input2 -i input3 -i input4 -i input5 \ -filter_complex \ "[0:v]pad=iw*3:ih*2[tl]; \ [tl][1:v]overlay=w[tc]; \ [tc][2:v]overlay=w*2[tr]; \ [tr][3:v]overlay=0:h[bl]; \ [bl][4:v]overlay=w:h[bc]; \ [bc][5:v]overlay=w*2:h[out]" \ -map "[out]" output.mp4 </code></pre> <p><code>[0:v]</code> is a <a href="https://ffmpeg.org/ffmpeg.html#Stream-specifiers-1" rel="noreferrer">stream specifier</a> and refers to the video stream of the first input. Since ffmpeg counts from 0 then <code>[4:v]</code> is the video stream of the fifth input.</p> <p><code>[tl]</code> is an example of a link label. In this example it was my way of saying "top left" and <code>[bc]</code> is short for "bottom center", but you can use just about any arbitrary name.</p> <h3>overlay with <code>setpts</code></h3> <p>Be aware that frames are taken from each input video in timestamp order, so if their initial timestamps differ it is a a good idea to use <code>setpts=PTS-STARTPTS</code> for each input to have them begin in the same zero timestamp:</p> <pre><code>ffmpeg -i input0 -i input1 -i input2 -i input3 -i input4 -i input5 \ -filter_complex \ "[0:v]setpts=PTS-STARTPTS[v0]; \ [1:v]setpts=PTS-STARTPTS[v1]; \ [2:v]setpts=PTS-STARTPTS[v2]; \ [3:v]setpts=PTS-STARTPTS[v3]; \ [4:v]setpts=PTS-STARTPTS[v4]; \ [5:v]setpts=PTS-STARTPTS[v5]; \ [v0]pad=iw*3:ih*2[tl]; \ [tl][v1]overlay=w[tc]; \ [tc][v2]overlay=w*2[tr]; \ [tr][v3]overlay=0:h[bl]; \ [bl][v4]overlay=w:h[bc]; \ [bc][v5]overlay=w*2:h[out]" \ -map "[out]" output.mp4 </code></pre> <h3>overlay with <code>setpts</code> and text</h3> <pre><code>ffmpeg -i input0 -i input1 -i input2 -i input3 -i input4 -i input5 \ -filter_complex \ "[0:v]setpts=PTS-STARTPTS,drawtext=fontfile=/Library/Fonts/Arial.ttf:fontsize=30:text='vid0':x=(w-text_w)/2:y=(h-text_h-line_h)/2[v0]; \ [1:v]setpts=PTS-STARTPTS,drawtext=fontfile=/Library/Fonts/Arial.ttf:fontsize=30:text='vid1':x=(w-text_w)/2:y=(h-text_h-line_h)/2[v1]; \ [2:v]setpts=PTS-STARTPTS,drawtext=fontfile=/Library/Fonts/Arial.ttf:fontsize=30:text='vid2':x=(w-text_w)/2:y=(h-text_h-line_h)/2[v2]; \ [3:v]setpts=PTS-STARTPTS,drawtext=fontfile=/Library/Fonts/Arial.ttf:fontsize=30:text='vid3':x=(w-text_w)/2:y=(h-text_h-line_h)/2[v3]; \ [4:v]setpts=PTS-STARTPTS,drawtext=fontfile=/Library/Fonts/Arial.ttf:fontsize=30:text='vid4':x=(w-text_w)/2:y=(h-text_h-line_h)/2[v4]; \ [5:v]setpts=PTS-STARTPTS,drawtext=fontfile=/Library/Fonts/Arial.ttf:fontsize=30:text='vid5':x=(w-text_w)/2:y=(h-text_h-line_h)/2[v5]; \ [v0]pad=iw*3:ih*2[tl]; \ [tl][v1]overlay=w[tc]; \ [tc][v2]overlay=w*2[tr]; \ [tr][v3]overlay=0:h[bl]; \ [bl][v4]overlay=w:h[bc]; \ [bc][v5]overlay=w*2:h[out]" \ -map "[out]" output.mp4 </code></pre> <h3>other stuff</h3> <ul> <li><p>Using <code>shortest=1</code> in the <code>overlay</code> filter will force the output to terminate when the shortest input terminates.</p></li> <li><p>Adding <code>format=yuv420p</code> at the end of your <a href="https://ffmpeg.org/ffmpeg-filters.html#Filtergraph-description" rel="noreferrer">filtergraph</a> will ensure your output uses a compatible pixel format for "dumb" players like QuickTime (this is not usually required but depends on the encoder and your input formats). Alternatively, you could use the <code>-pix_fmt yuv420p</code> output option but is less flexible than placing it wherever you want in your filtergraph.</p></li> <li><p>See the <a href="https://ffmpeg.org/ffmpeg-filters.html#pad" rel="noreferrer"><code>pad</code></a>, <a href="https://ffmpeg.org/ffmpeg-filters.html#overlay-1" rel="noreferrer"><code>overlay</code></a>, <a href="https://ffmpeg.org/ffmpeg-filters.html#setpts_002c-asetpts" rel="noreferrer"><code>setpts</code></a> and <a href="https://ffmpeg.org/ffmpeg-filters.html#drawtext-1" rel="noreferrer"><code>drawtext</code></a> filter documentation for more information and examples.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload