Table of contents
ffmpeg
install ffmpeg
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg
flags
-i [file] input file
-map [index]:[track] map only the selected track(s) for input file specified with index
-itsoffset [offset] apply offset (to the input file that follows it)
-c:a copy copy audio; don't re-encode
-c:v copy copy video; don't re-encode
-acodec copy copy audio; don't re-encode
-vcodec copy copy video; don't re-encode
-filter:a "volume=2" scale audio 2x as loud
-nostdin disable stdin (stdin breaks scripts)
commands
show file info (Stream #0:1 = input file 0, track 1)
ffmpeg -i [file]
show tracks only
ffmpeg -i [file0] -i [file1] 2>&1 | grep Stream
re-encode to another file format
ffmpeg -i source.mp4 output.webm
delay video by 0.5 seconds
ffmpeg -i $input -itsoffset 0.5 -i $input -map 0:v -map 1:a -acodec copy -vcodec copy $output
delay audio by 0.5 seconds
ffmpeg -i $input -itsoffset 0.5 -i $input -map 0:a -map 1:v -acodec copy -vcodec copy $output
extract a chunk from a video file
ffmpeg -i [input file] -ss 0.50 -to 1 -acodec copy -vcodec copy [output file]
ffmpeg -i [input file] -ss 1 -to 2 -acodec copy -vcodec copy [output file]
ffmpeg -i [input file] -ss 1:02 -to 2:04 -acodec copy -vcodec copy [output file]
ffmpeg -i [input file] -ss 0:01:02 -to 0:02:04 -acodec copy -vcodec copy [output file]
ffmpeg -i [input file] -ss 0:01:02.00 -to 0:02:04.00 -acodec copy -vcodec copy [output file]
re-encode with a bitrate of 350.000 (to shrink file)
ffmpeg -i source.mp4 -b 350000 destination.mp4
re-encode with a single frame per second (to shrink file)
ffmpeg -i source.mp4 -r 1 destination.mp4
multiply volume (raise/lower volume)
ffmpeg -i $input -filter:a "volume=2" $output
cropping
ffmpeg -i $input -filter:v "crop=w=800:h=600" $output
ffmpeg -i $input -filter:v "crop=w=800:h=600:x=400:y=400" $output
ffmpeg -i $input -filter:v "crop=w=1/4*in_w:h=1/4*in_h" $output
scaling
ffmpeg -i $input -vf scale=480:320 $output
ffmpeg -i $input -filter:v "scale=w=800:h=600" $output
ffmpeg -i $input -filter:v "scale=w=1/4*in_w:h=1/4*in_h" $output
rotation
ffmpeg -i $input -filter:v "rotate=1.5*PI" $output
ffmpeg -i $input -filter:v "rotate=180/360*2*PI" $output
config file (multiple chunks)
config file listing multiple chunks
file input.mp4
inpoint 5:42
outpoint 10:55
file input.mp4
inpoint 16:26
outpoint 19:17
file input.mp4
inpoint 24:19
outpoint 26:55
extract chunks listed in [config-file]
ffmpeg -f concat -i [config-file] -c:v copy -c:a copy [output-file]
documentation
https://trac.ffmpeg.org/wiki