View Full Version : 2-Pass Mencoder, Good Method?
blazerqb11
26th November 2008, 20:36
I have been using mencoder for x264 encodes, but I'm not sure if I am correctly using the 2-pass option. In Windows I have tried:
mencoder "infile.mkv" -ovc x264 -x264encopts bitrate=3333: pass=1:threads=2 -oac copy -o nul
followed by
mencoder "infile.mkv" -ovc x264 -x264encopts bitrate=3333: pass=2:threads=2 -oac copy -o "outfile.mkv"
It finishes with no problems but I am not sure if it is actually working. Will these lines result in an actual 2-pass encode?
Also, on a related note what is a good way to do a 2-pass encode using x264? Looking around it seems like most people here are using the x264 program to do their encodes, should I be using that?
LoRd_MuldeR
26th November 2008, 20:42
To run a 2-Pass encode with x264, you run the first pass with "--pass 1" and the second one with "--pass 2".
Also you specify the same bitrate via "--bitrate x" for both passes. So your arguments (in MEncoder syntax) look correct to me.
But I can't see "--stats filename" or a MEncoder equivalent. How do you specify the stats file ???
BTW: Since the x264 CLI encoder and MEncoder use the same x264 code, there should be no difference between the results.
However you should make sure to get a MEncoder build with a recent x264 revision. Usually it's easier to find recent x264 CLI builds.
You can even compile your own x264.exe easily...
(Sidenote: How many CPU cores do you have? For x264 you should set "--threads x" to number_of_cores * 3/2)
blazerqb11
26th November 2008, 21:13
From what I have been able to gather from researching online, you are suppose to specify the outfile as nul, or at least /dev/null in Linux which nul is the equivalent of in Windows. As far as the statfile, I never could never find anything specific as to where it was stored and that is a large part of why I'm not too sure what I am doing is correct.
My CPU has 2 cores, so you are saying I should set it to 3 threads?
LoRd_MuldeR
26th November 2008, 21:26
From what I have been able to gather from researching online, you are suppose to specify the outfile as nul, or at least /dev/null in Linux which nul is the equivalent of in Windows. As far as the statfile, I never could never find anything specific as to where it was stored and that is a large part of why I'm not too sure what I am doing is correct.
You can set the output to "NUL" for the first pass, because you would overwrite that file anyway in the second pass.
But it's not necessary, it just avoids some unnecessary HDD activity during first pass...
And I think "-passlogfile <filename>" is the proper MEncoder syntax to specify the stats file for a 2-Pass encode.
My CPU has 2 cores, so you are saying I should set it to 3 threads?
Exactly ;)
nm
26th November 2008, 21:40
As far as the statfile, I never could never find anything specific as to where it was stored and that is a large part of why I'm not too sure what I am doing is correct.
By default, the stats file is named divx2pass.log (divx2pass.log.temp while encoding the first pass). As LoRd_MuldeR said, use -passlogfile to change it.
My CPU has 2 cores, so you are saying I should set it to 3 threads?
Or to 0 or auto to let x264 use the right number of threads automatically.
blazerqb11
26th November 2008, 22:47
Thanks, you guys have been a huge help. So my previous script is correct in that it would store the statsfile in divx2pass.log and not write any actual video for the first pass.
Let me take a stab at another script with a specified log file.
mencoder "infile.mkv" -ovc x264 -x264encopts bitrate=3333: pass=1:threads=3 -passlogfile "c:\video\logs\logfile.log" -oac copy -o nul
Now do I have to include the logfile again in the second pass to point to it? e.g.:
mencoder "infile.mkv" -ovc x264 -x264encopts bitrate=3333: pass=2:threads=3 -passlogfile "c:\video\logs\logfile.log" -oac copy -o "outfile.mkv"
froggy1
26th November 2008, 22:56
@ blazerqb11
yes
LoRd_MuldeR
26th November 2008, 22:57
Now do I have to include the logfile again in the second pass to point to it?
Re-using the log file created during the first pass in the second pass is the entire point of a 2-Pass encode ;)
If you don't re-use the log file, the first pass was completely pointless...
blazerqb11
27th November 2008, 01:20
Re-using the log file created during the first pass in the second pass is the entire point of a 2-Pass encode ;)
If you don't re-use the log file, the first pass was completely pointless...
Yes, I was just curious if that was the correct way to point mencoder to the log file, or if mencoder stored where it was, or any number of other possibilities.
LoRd_MuldeR
27th November 2008, 01:40
Yes, I was just curious if that was the correct way to point mencoder to the log file, or if mencoder stored where it was, or any number of other possibilities.
Nope, MEncoder is "stateless", it doesn't remember anything from previous encodes.
For each pass MEncoder needs to be provided with all the required parameters. The same applies to the x264 CLI encoder...
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.