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 janozer@gmail.com.

Thanks!

Encoding cost & efficiency review

Impressed with this analysis? Your encoding ladder deserves the same scrutiny.

Our encoding cost and efficiency review tests your ladders and codec configurations on your own content, cutting bandwidth spend without sacrificing quality. You get lower delivery bills and better viewer QoE.

See how it works →

About Jan Ozer

Avatar photo
I help streaming and video technology companies solve complex technical and market-facing problems in practical business terms. Engagements range from fixed-scope audits and codec strategy reviews to product testing and technical content that helps customers, prospects, and internal teams connect technical performance to business outcomes. 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.

Check Also

Microsoft MLVC: Interoperability, Power Realities, and the Neural Compression Patent Landscape

Microsoft recently open-sourced the Machine Learning Video Codec (MLVC) under the MIT License, publishing the …

Codecs for CFOs

Executive Summary The H.264 codec has proven remarkably durable, but demand for 4K efficiency, HDR …

Wowza’s New Video Intelligence Framework – Interviews

Wowza just released the Video Intelligence Framework, or VIF. According to my article in Streaming …

Leave a Reply

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