What’s the Best Setting for x265 Two-Pass Encoding?

I’m running some 1-pass vs. 2-pass comparison testing with x265. Unlike with x264 (see tests here), there’s a substantial performance penalty for running 2-pass with minimal quality benefit.

I tried the no-slow-firstpass=1 setting, which only accelerated two-pass by about 14%. Here are the results from a single test file. I don’t want to process them all if there’s a magic switch that accelerates two-pass x265.

As you can see in the table above, turbo mode reduced encoding time from 4:52 to 4:12, with just a slight decrease in quality. Single-pass encoding was about 45% faster than the two-pass turbo, and at least for this file, produced slightly higher quality; a man bites dog results. 

The command strings were pretty generic.

One Pass

ffmpeg -y -i football.mp4 -c:v libx265 -preset medium -threads 8 -b:v 3500k -maxrate 7000k -bufsize 7000k -g 60 -x265-params open-gop=0  football_1pass.mp4

Two Pass – Baseline

ffmpeg -y -i football.mp4 -c:v libx265 -preset medium -threads 8 -b:v 3500k -maxrate 7000k -bufsize 7000k -g 60 -x265-params open-gop=0:pass=1:no-slow-firstpass=1 -f mp4 NUL
ffmpeg -y -i football.mp4 -c:v libx265 -preset medium -threads 8 -b:v 3500k -maxrate 7000k -bufsize 7000k -g 60 -x265-params open-gop=0:pass=2 -an football_2pass.mp4

Two Pass – Turbo

ffmpeg -y -i "football.mp4" -c:v libx265 -preset medium -threads 8 -b:v 3500k -maxrate 7000k -bufsize 7000k -g 60 -x265-params open-gop=0:pass=1:no-slow-firstpass=1 -f mp4 NUL
ffmpeg -y -i "football.mp4" -c:v libx265 -preset medium -threads 8 -b:v 3500k -maxrate 7000k -bufsize 7000k -g 60 -x265-params open-gop=0:pass=2 -an football_2pass_turbo.mp4

If anyone knows a better alternative for accelerating the first pass of x265, please LMK at [email protected].

Thanks!

About Jan Ozer

Avatar photo
I help companies train new technical hires in streaming media-related positions; I also help companies optimize their codec selections and encoding stacks and evaluate new encoders and codecs. I am a contributing editor to Streaming Media Magazine, writing about codecs and encoding tools. I have written multiple authoritative books on video encoding, including Video Encoding by the Numbers: Eliminate the Guesswork from your Streaming Video (https://amzn.to/3kV6R1j) and Learn to Produce Video with FFmpeg: In Thirty Minutes or Less (https://amzn.to/3ZJih7e). I have multiple courses relating to streaming media production, all available at https://bit.ly/slc_courses. I currently work as www.netint.com as a Senior Director in Marketing.

Check Also

Evaluating DCVC-RT: A Real-Time Neural Video Codec That Delivers on Speed and Compression

Background Authors & Affiliations: Zhaoyang Jia and Linfeng Qi (USTC), Bin Li, Jiahao Li, Wenxuan …

Google’s Cookie Reversal: While Advertisers Rejoice, Legal Trouble Lurks in the Weeds

Google just kicked the can down the road—again—on killing third-party cookies in Chrome. While much …

HEVC Licensing: Misunderstood, Maligned, and Surprisingly Successful

I’ve been involved in a seemingly never-ending debate that started with the dubious (to me) …

Leave a Reply

Your email address will not be published. Required fields are marked *