Skip to content

Instantly share code, notes, and snippets.

@flyingluscas
Last active October 5, 2022 13:11
Show Gist options
  • Save flyingluscas/f355e2ff830176fbc732b35e2c19b598 to your computer and use it in GitHub Desktop.
Save flyingluscas/f355e2ff830176fbc732b35e2c19b598 to your computer and use it in GitHub Desktop.
FFMPEG Optimize videos for YouTube

Command

$ ffmpeg -i <input file> -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart <output_name>.mp4

Function

function youtube () {
	( ffmpeg -i $1 -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart $2.mp4 )
}

Source from this article

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment