Skip to content

Instantly share code, notes, and snippets.

@quyenlv
Last active January 15, 2019 08:13
Show Gist options
  • Save quyenlv/87e323015a20e5962dfe4a7afb8a5798 to your computer and use it in GitHub Desktop.
Save quyenlv/87e323015a20e5962dfe4a7afb8a5798 to your computer and use it in GitHub Desktop.
Encode video using ffmpeg.

Encoding

Encode video for uploading to Youtube/Vimeo. The output should be a similar quality as the input and will hopefully be a more manageable size.

ffmpeg -i input.avi -c:v libx264 -preset slow -crf 18 -c:a copy -pix_fmt yuv420p output.mkv

Same as above, but also re-encode the audio using AAC instead of stream copying it:

ffmpeg -i input.mov -c:v libx264 -preset slow -crf 18 -c:a aac -b:a 192k -pix_fmt yuv420p output.mkv

Compressing

Compress video. Vary the CRF between around 18-24 (best-lower quality):

ffmpeg -i input.mp4 -vcodec libx264 -crf 24 -acodec aac output.mp4

Reference

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