Encoding errors from ffmpeg x265 pass 2 which succeeded in pass 1.

Hi I am Rupesh from India and I have a PC with Linux installed and I have large size YouTube and WhatsApp MP4 files with codec x264. I want to convert these files into MP4 files with codec x265.

I have tested to convert these files using ffmpeg command x265 pass 1 and Linux shell script and I have successfully completed without any errors but I want to use ffmpeg tool x265 pass 2 to do the same job but I can’t.

I got the following code from ffmpeg website and first I have tried to convert a single file and after that I have tried to use the similar code in Linux shell script.


ffmpeg -y -i source.mp4 -filter_threads 3 -profile:v main -preset medium -c:v libx265 -x265-params pass=1 -an -f null /dev/null && \

  ffmpeg -i source.mp4 -c:v libx265 -x265-params pass=2 -c:a aac -b:a 48k -ar 44100 source_compressed.mp4

Upon running the above command I am able to see .log and .cue files in the current directory.

For all cases I got only the following two errors.



[libx265 @ 0x742200] Cannot open libx265 encoder.

Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

[aac @ 0x745300] Qavg: 33846.148

[aac @ 0x745300] 2 frames left in the queue on closing

Conversion failed!

localhost:~/to convert # 




[libx265 @ 0x10e43c0] Cannot open libx265 encoder.

Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Conversion failed!

The code I have executed without pass 2 is the following.


ffmpeg -y -i source.mp4 -filter_threads 3 -profile:v main -preset medium -c:v libx265 -c:a aac -b:a 48k -ar 44100 source_compressed.mp4

Can you suggest why I can’t do the same job in pass 2 of ffmpeg command which has been successfull in pass 1 of ffmpeg command x265.

The error message is very clear. YOu have the wrong options, and you’re trying to run pass 2 without first running pass 1. Read the man pages on ffmpeg and x265.