I have a 10bit video and want to encode it using x265 (HEVC) code. How can I do 2-pass encoding for the same?
Hey Albert,
FFmpeg provides the best ways to transcode a video. To transcode/encode 10-bit video with HEVC you just need to set the video profile to main10 which supports 10bit.
Consider the following command as an example.
# First pass
ffmpeg -i input.mp4 -c:v libx265 -b:v 1500k -x265-params pass=1 -f null -
# Second pass
ffmpeg -i input.mp4 -c:v libx265 -b:v 1500k -x265-params pass=2 -c:a copy output.mp4
In the above command,
- The input video file is specified by the
-i input.mp4
flag. -c:v libx265
uses the libx265 library to set the video codec to HEVC.- The video bitrate target is set to
-b:v
1500k. Taking into account your intended bitrate, you should modify this value. - This is the first pass, as indicated by
-x265-params pass=1
. The first pass’s output is null (-f null -), indicating that statistics are collected rather than a real video file being generated. -x265-params pass=2
designates this as the second pass in the second pass. The first pass’s statistics are used to encode the video.-c:a
copy does not re-encode the audio stream; it simply copies it.
Note: Based on your unique needs, change the bitrate (-b:v), codec parameters (-x265-params), and other settings.
This is a basic example; depending on the qualities and characteristics of your video, you might need to adjust the parameters to achieve the desired compression and quality.
Thanks for your reply!
BTW, How can I use CRF with 2-pass HEVC 10bit encode?
Pass encoded with CRF (constant rate factor) is not possible, you have to use either a 2-pass or CRF rate control method. Consider the following command as an example for CRF encode.
ffmpeg -i input -c:v libx265 -crf 26 -preset fast -x265-params profile=main10 -c:a aac -b:a 128k output.mp4