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

DCVC-B: A New Deep Learning Codec for Efficient B-Frame Compression

In a recent white paper titled Bi-Directional Deep Contextual Video Compression (DCVC-B), researchers Xihua Sheng, …

M3-CVC: A Glimpse into the Future of AI-Driven Video Compression

A new AI-based codec proved 18% more efficient than VVC but substantial decoding requirements will …

Comparing Fixed GOPs to Variable GOPs with I-Frames at Scene Changes

I first encountered the line, “Anything worth doing is worth overdoing,” in the Robert Heinlein …

Leave a Reply

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