ffmpeg \
-r 30000/1001 \
-pattern_type glob -i '*.JPG' \
-vf "crop=in_w:in_w*9/16,scale=3840:-2" \
-sws_flags lanczos \
-pix_fmt yuv420p \
-vcodec libx264 \
-crf 18 -preset slow \
output.mkv
-r 30000/1001
- 30 fps frame rate. Why divide by 1001? See drop-frame timecode.-pattern_type glob -i '*.JPG'
- all JPG files in the current directory. Note this is case sensitive.-vf "crop=in_w:in_w*9/16,scale=3840:-2"
- 4k UHD. GoPro captures in 4000x3000, so need to crop it to 16:9 resolution. Change3840
to1920
if you want HD 1080p resolution.-sws_flags lanczos
- I want to scale Gaussian or lanczos, I think it’s better than bicubic.-pix_fmt yuv420p
- Required to support Quicktime.-vcodec libx264
- everyone is using this codec - but why?-crf 18 -preset slow
- Add this for better quality output.output.mkv
- Output filename. Change to.mp4
if you want MP4.
This is not required as long as you use the crop
option in ffmpeg
, but is included for reference in case you want to crop the images with ImageMagick first before feeding them into ffmpeg
(this is slower than using ffmpeg
directly).
find . -name '*.JPG' -exec convert {} -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' "{}_cropped.jpg" \;