ffmpeg
Setting Up
You should know that a lot of other programs bundle copies of ffmpeg when they're distributed, most notably ImageMagick, Blender and most video editors.
So don't do what I did and fail to check whether your actual ffmpeg installation has path priority over one of these other versions. I discovered recently to my horror that I had been using a five year old version of it thanks to an ImageMagick choco upgrade bumping its path priority above ffmpeg, which caused all kinds of head-scratchers as I tried to work out why a program I hadn't updated in six months was now refusing commands I'd been running every single day.
Making GIFs
ffmpeg -i file.mp4 -vf "fps=12,scale=680:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" out.gifThis generates relatively small GIF files but the choice of 680 for the width will naturally produce something quite large. The second value of the scale as -1 ensures the aspect ratio is preserved.
Using the trimming controls, you can also specify the section of the video you want.
ffmpeg -i file.mp4 -ss 02:05 -t 6 -vf "fps=12,scale=680:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" out.gifThis creates a GIF that starts at 2 minutes and 5 seconds and lasts 6 seconds.
Random Things
Trimming a file
-ss 00:00:05
-to 00:00:10
-t 8The first two represent fixed time timestamps in the input video, like slicing out the footage between two markers. You can omit -ss and just use -to if you're wanting to cut the video short and vice-versa if you're just trimming air from the front. -t simply sets a length in seconds from the start time for relative trimming.
ffmpeg -i input.mp4 -ss 01:19:27 -to 02:18:51 -c copy output.mp4Remove a chunk from the middle of video
ffmpeg -i input.mp4 -vf "select='not(between(t,9,20))', setpts=N/FRAME_RATE/TB" -af "aselect='not(between(t,9,20))', asetpts=N/SR/TB" output.mp4The setpts/asetpts filters set the timestamps on each frame to the correct values so that playback doesn't skip.
Remove Audio
ffmpeg -i input.mp4 -c copy -an output.mp4Copy with a new stream as the main one
ffmpeg -i input.mp4 -map 0:v:0 -map 0:a:1 -vf "scale=1920x1080" output.mp4Set metadata field
ffmpeg -i input.mp4 -metadata title="New Title" -codec copy output.mp4DNxHR Encoding
ffmpeg -c:v dnxhd -profile:v dnxhr_444 -pix_fmt yuv444p10le| Quality | Pixel Encoding | Bit Depth | Profile | Pixel Format |
|---|---|---|---|---|
| Low Bandwidth | 4:2:2 | 8 | dnxhr_lb | yuv422p |
| Standard | 4:2:2 | 8 | dnxhr_sq | yuv422p |
| High | 4:2:2 | 8 | dnxhr_hq | yuv422p |
| High | 4:2:2 | 10 | dnxhr_hqx | yuv422p10le |
| Finishing | 4:4:4 | 10 | dnxhr_444 | yuv444p10le |
Your profile must match your pixel format as per this table, otherwise you'll get errors.
De-interlacing DVDs
These commands de-interlace .vob files into DNxHR files (see settings above).
ffmpeg -y -hide_banner -loglevel warning -i orig/disc_c.vob -vf bwdif -c:v dnxhd -profile:v dnxhr_sq -pix_fmt yuv422p -an trans/disc_c.movDVD de-interlacing can use a number of different filters —
yadif # very fast
yadif_cuda # experiment with this, because it usually doesn't work
bwdif # seemingly better quality than yadif, though hard to perceive
nnedi # seemingly the best, but doesn't work without additional librariesYou also need to encode the audio correctly —
ffmpeg -i input.vob -vf yadif -c:v libx264 -preset slow -crf 19 -c:a aac -b:a 256k output.mp4