Skip to content

Instantly share code, notes, and snippets.

@santurini
Created June 4, 2023 17:49
Show Gist options
  • Save santurini/4a1343d2bab2f638643ca518c0acc4e7 to your computer and use it in GitHub Desktop.
Save santurini/4a1343d2bab2f638643ca518c0acc4e7 to your computer and use it in GitHub Desktop.
Processing videos with ffmpeg.
compressing a video
ffmpeg -i "$input_video" -vf fps=$fps -c:v libx264 -an -preset veryslow -crf $crf "$output_video"
trimming a video to 20 seconds
ffmpeg -i "$input_video" -ss "00:00:00" -t "00:00:20" "$output_video"
scaling a video
ffmpeg -i "$input_video" -vf scale=$height:$width:flags=accurate_rnd "$output_video"
taking a center crop
ffmpeg -i "$input_video" -vf crop=$crop_w:$crop_h:(in_w-$crop_w)/2:(in_h-$crop_h)/2 "$output_video"
converting video to frames
ffmpeg -i "$input_video" "$output_dir/img%05d.png"
converting frames to video
ffmpeg -framerate $fps -pattern_type glob -i "$video_folder"/'*.png' -c:v libx264 "$output_video"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment