Skip to content

Instantly share code, notes, and snippets.

@kobybibas
Last active March 14, 2021 12:48
Show Gist options
  • Save kobybibas/a3b76829ba42deffe883b2bcb02d466a to your computer and use it in GitHub Desktop.
Save kobybibas/a3b76829ba42deffe883b2bcb02d466a to your computer and use it in GitHub Desktop.
Crop, scale and compress a video
# Crop such that the output is heightxheight. Then scale to 640:640. finally videeo compression ("28", higher is more compression)
ffmpeg -i intput -filter:v "crop=ih:ih,scale=640:-2" -crf 28 output.mp4
# Split a video to 280 sec segments
ffmpeg -i input.mp4 -acodec copy -f segment -segment_time 280 -vcodec copy -reset_timestamps 1 -map 0 output_%d.mp4
# Crop with side by side merge (https://stackoverflow.com/questions/35349935/ffmpeg-crop-with-side-by-side-merge)
ffmpeg -i in0.mp4 -i in1.mp4 -filter_complex "[0:v]crop=iw/2:ih:0:0[left]; [1:v]crop=iw/2:ih:ow:0[right]; [left][right]hstack" output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment