failed to rename “x264_2pass.log.temp” to “x264_2pass.log”

If you’re not running FFMPEG directly (running a GUI wrapper for instance) I don’t have an answer for you. But if you’re running FFMPEG directly from the command line you might run into this if you run multiple encodes at the same time.

Specifically, FFMPEG allows you to specify the 2-pass logfile but doesn’t allow you to specify x264’s 2-pass logfile. So if you run multiple 2-pass encodes at the same time they’ll both try to write to the same logfile (which seems to not fail) during the first pass but the first one to finish tries to rename the file and fails with:

failed to rename "x264_2pass.log.temp" to "x264_2pass.log".
[libx264 @ 0x19db1f0]ratecontrol_init: can't open stats file
Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

Then the encoder that failed might also kick out this error message while trying to make the second pass:

[libx264 @ 0x2606ad0]statistics are damaged at line 2130, parser out=0
Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

The solution? The only solution I have so far is to copy FFMPEG to a unique folder for each 2-pass encode because the x264 logs will be created in the same folder as FFMPEG.exe. If anyone has another option I’d love to hear it.

UPDATE 2009-06-30

I’m launching FFMPEG from .Net and I found that if I just set the WorkDirectory of the process to a unique folder instead of copying the EXE every time it works perfectly, too.

2 thoughts on “failed to rename “x264_2pass.log.temp” to “x264_2pass.log”

  1. Thanks a bunch for figuring this out. The problem seems to go back a ways according to google, and you apparently nailed it!

  2. Thanks man, you nailed it. My encodes were working every time in dev and on my box, but in production where they are multi-threaded I kept getting 0 byte files. This is why. Setting the Working Directory of the process resolved my issues. Thank you!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.