ffmpeg.exe Command-Line Examples

Updated on 5/14/2016

Create a Composite of Two Video Files

The following will take two video files and make them into one video that shows both source videos at the same time.

ffmpeg.exe  -i "video_input.mp4" -i "chat_input.mp4" -ss 00:07:36 -t 00:00:09 
-filter_complex "[0:v]setpts=PTS-STARTPTS, scale=1488:838[video]; color=c=black:size=1920x1080[bg]; [1:v]setpts=PTS-STARTPTS[chat]; [bg][video]overlay=shortest=1:x=0:y=121[ol1]; [ol1][chat]overlay=shortest=1:x=1488:y=50" "output.mp4"
Parameters Description
-ss Timestamp from the input file of when the output video should start
-t Duration of the output video
-filter_complex String that defines how to compose the output file streams
[0:v]setpts=PTS-STARTPTS, scale=1488:838[video]; Take the video from the first input [0:v], scale it, and store it in variable [video]
color=c=black:size=1920x1080[bg]; Create a black background and store it in [bg]
[1:v]setpts=PTS-STARTPTS[chat]; Take the video from the second input [1:v], and store it in [chat]
[bg][video]overlay=shortest=1:x=0:y=121[ol1]; Overlay [video] onto [bg] at the given quardinates (0,121). Store this in [ol1]
[ol1][chat]overlay=shortest=1:x=1488:y=50 Overlay [chat] onto [ol1] at the given quardinates (1488,50]. No output variable is stored as this is the final result that we want to output.


Concatenate Multiple Video Files

The following will take a list of video files and join them into one file.

ffmpeg.exe -f concat -i "ffmpeg_concat_list.txt" -c copy "output.mp4"
ffmpeg_concat_list.txt contents
file 'e:\part1.mp4'
file 'e:\part2.mp4'
file 'e:\part3.mp4'


Create a Clip from a Video File

This example creates a clip from a video file. The clip will start 23.7 seconds (-ss) into the file and will be 6 seconds (-t) long.

ffmpeg.exe -i "input.mp4" -ss 00:00:23.7 -t 00:00:06.0 "output_clip.mp4"


Fix Audio Sync Issues

In this example, the audio is shifted 3.8 seconds (-itsoffset). Notice that the same file is input twice, once for the video stream and once for the audio stream.

ffmpeg.exe -i "input.mp4" -itsoffset -3.8 -i "input.mp4" -map 0:0 -map 1:1 -acodec copy -vcodec copy "output.mp4"


Fix a Broken File

Attempt to fix a bad file by recreating the index. This will not fix everything.

ffmpeg.exe -i "input.mp4" -vcodec copy -acodec copy "output.mp4"