How to cut video with FFmpeg and insert titles

2011-11-12

How to cut video and insert titles in between.

  1. To cut a scene from the longer video:

    ffmpeg -ss HH:MM:SS -t SECONDS -sameq -i original.mov clip.mpg
    

    where HH:MM:SS is starting position.

  2. To create an image with titles (black frame, white letters):

    convert -background black -fill white -size WIDTHxHEIGHT -pointsize 24 -gravity center \
    label:Your\ title\ here\\nAnd\ subtitle\ too title.jpg
    

    Using ImageMagick here. To see WIDTHxHEIGHT of your input stream, run ffmpeg -i original.mov.

  3. To convert static image to video with a silent audio track (25 frames = 1 second here):

    ffmpeg -shortest -loop_input -f image2 -i title.jpg -r 25 -vframes 25 \
    -ar 44100 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -acodec mp2 title.mpg
    
  4. To merge (concatenate) two or more videos together:

    cat title.mpg clip.mpg | ffmpeg -sameq -f mpeg -i - finalcut.mpg