FFMPEG notes
Basic usage
ffmpeg -i input.mp4 output.mp4
Scale video to height 1080p
ffmpeg -i input.mp4 -vf "scale=-2:1080" output.mp4
Remove audio track from a video file
ffmpeg -i input.mp4 -an output.mp4
Slow down a video
https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
ffmpeg -i "$infile" -filter:v "setpts=2.0*PTS" "slowmo-$infile"
Interpolate videos to high fps
ffmpeg -i input.mkv -filter:v "minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=120" output.mkv
Concat video files
# mylist.txt file format
# this is a comment
file '/path/to/file1.mp4'
file '/path/to/file2.mp4'
file '/path/to/file3.mp4'
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
Cut video files
Following example cuts a video from 5 seconds to 10 seconds and exports it. Alternatively, use this software
ffmpeg -ss 00:05 -to 00:10 -i input.mkv -c copy output.mp4
Side by side 2 videos
Note that the videos must be same height. And amerge channels needs to be chosen properly.
ffmpeg -i input0 -i input1 -filter_complex "[0:v]scale=-2:1080,left[main]; [1:v]scale=-2:1080,right[alt]; [main][alt]hstack=inputs=2[outv]; [0:a][1:a]amerge=inputs=2[outa]" -map [outv] -map [outa] out.mp4
Export a frame as image
Use -ss option to specify frame timestamp
ffmpeg -ss 00:05 -i input.mp4 -q:v 1 -vframes 1 out.jpg
Side by side 2 images
Using same options as side by side video.
ffmpeg -i input1.jpg -i input2.mp4 -filter_complex "[0:v]scale=-2:1080[left]; [1:v]scale=-2:1080[right]; [left][right]hstack=inputs=2[video]" -map "[video]" -q:v 1 -frames:v 1 out.jpg
Filters to transpose / flip / rotate:
Flip:
-vf "hflip" -vf "vflip"
Rotate:
-vf "transpose=0" -vf "transpose=1" -vf "transpose=2" -vf "transpose=3"
These commands use the -vf option to apply video filters to the input. hflip and vflip are the horizontal and vertical flip filters respectively, and transpose is a filter that can be used to rotate the input video by 90 degrees clockwise or counter-clockwise. The values of transpose are 0, 1, 2, and 3, which correspond to no rotation, 90 degrees counter-clockwise, 90 degrees clockwise, and 180 degrees respectively.
Convert a video to a gif
ffmpeg -y -i out.mp4 -r 30 -vf "scale=-2:1080,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" out.gif