Skip to content

Instantly share code, notes, and snippets.

@goyuix
Created February 6, 2018 17:32
Show Gist options
  • Save goyuix/3f31b2fd4dfd87d49d2bfd79323146d0 to your computer and use it in GitHub Desktop.
Save goyuix/3f31b2fd4dfd87d49d2bfd79323146d0 to your computer and use it in GitHub Desktop.
Sample ffmpeg encode for x265 HEVC web-optimized MP4
ffmpeg -i input.mkv -movflags faststart -c:v libx265 -crf 25 -c:a aac -b:a 128k output.mp4
Copy link

ghost commented May 3, 2020

  1. You should use .mkv as the output file-extension. It is optimized for h.265 encoding. Plus, the mkv container already has the ATOM at the start of the file https://trac.ffmpeg.org/wiki/Encode/YouTube#faststartforMP4M4VMOVfiles. YouTube supports upload of .mkv-files.
  2. If you'll stick with the .mp4 extension, fix the way you use the flag: -moveflags "+faststart". The "-wrapping is for Windows' users.
  3. Optionally specify a preset. The quality stays the same, it only matters in the file-size. I use -preset ultrafast to be just done with it, but alternatively you may also use -preset veryslow (will took much longer but the file-size will be smaller).
  4. 25 is quite too low. h.265's default is CRF-28 which quality-wise is same as h.264's default of CRF-23 (half the file-size).

https://trac.ffmpeg.org/wiki/Encode/H.265 vs. https://trac.ffmpeg.org/wiki/Encode/H.264

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