Table of Contents

ffmpeg - Encoding - h265 - Two-Pass Encoding

Used if targeting a specific output file size and output quality from frame to frame is of less importance.

This is best explained with an example.

For two-pass, ffmpeg is run twice, with almost the same settings, except for:

For libx265, the -pass option (that you would use for libx264) is not applicable.


Example

ffmpeg -y -i input -c:v libx265 -b:v 8000k -x265-params pass=1 -an -f null /dev/null && \
ffmpeg -i input -c:v libx265 -b:v 8000k -x265-params pass=2 -c:a aac -b:a 320k output.mp4

NOTE:

  • Windows users should use NUL instead of /dev/null and ^ instead of \.
  • As with CRF, choose the slowest -preset you can tolerate, and optionally apply a -tune setting.
    • When using faster presets with the same target bitrate, the resulting quality will be lower and vice-versa.

References