Log in

View Full Version : writting a log using x264 commandline


graysky
31st May 2007, 21:30
I'd like have the output of my x264.exe go into a text log file so I can keep book on my fps/encode time. I have tried adding a > log.txt after the command, but that just makes a 0-byte log file. Here is my commandline for the 1st pass, any help is appreciated.

x264.exe --pass 1 --bitrate 1386 --stats "C:\work2\test.stats" --bframes 3 --b-pyramid --direct auto --subme 1 --analyse none --vbv-maxrate 25000 --me dia --threads auto --thread-input --progress --no-dct-decimate --no-psnr --no-ssim --output NUL "C:\work2\test.avs"

That gives me the following outputted to my screen:
avis [info]: 720x480 @ 23.98 fps (336 frames)
x264 [info]: using cpu capabilities MMX MMXEXT SSE SSE2
x264 [warning]: VBV maxrate specified, but no bufsize.
x264 [info]: slice I:4 Avg QP:19.50 size: 3089100:00
x264 [info]: slice P:88 Avg QP:19.74 size: 15305
x264 [info]: slice B:244 Avg QP:21.68 size: 4049
x264 [info]: mb I I16..4: 26.6% 0.0% 73.4%
x264 [info]: mb P I16..4: 8.3% 0.0% 0.0% P16..4: 72.6% 0.0% 0.0% 0.0% 0
.0% skip:19.1%
x264 [info]: mb B I16..4: 0.4% 0.0% 0.0% B16..8: 23.2% 0.0% 0.0% direct:
17.3% skip:59.1%
x264 [info]: final ratefactor: 20.28
x264 [info]: direct mvs spatial:98.0% temporal:2.0%
x264 [info]: kb/s:1403.3

encoded 336 frames, 164.14 fps, 1403.72 kb/s

Honestly, all I want is the very last line that reports the fps for this pass; I'm not interested in the x264 [info] lines at all for this.

Thanks all!

J_Darnley
31st May 2007, 23:34
I think x264 uses stderr to report that information. Use this instead:

x264 [options] 2> log.txt

graysky
1st June 2007, 00:23
Thanks for the suggestion; it worked great. Is there a way to have both the text log as well a the screen log?

J_Darnley
1st June 2007, 01:22
Apparently you can. Use:

x264 [options] 2> log.txt 2>&1

Use the Windows XP (it may exists in other versions) Help & Support thing for more information on command redirection operators. >> should append the data to the file instead of overwriting. I think the a-z command line reference is just amazing.

graysky
1st June 2007, 01:39
I didn't see this stuff in the online help... what are you searching for specifically?

I also tried the x264 [options] 2> log.txt 2>&1 but all it did was output to the screen; no log was written.

Thanks again for info!

foxyshadis
1st June 2007, 02:07
You can use tee (http://unxutils.sourceforge.net/) to split output between stdout/err and another stream.

graysky
27th August 2007, 20:50
@foxyshadis: I have tee.exe now, but I have no idea how to use it to accomplish this :) I think tee is used for existing files, no?

graysky
27th August 2007, 21:07
What I'm really interested in doing is having the fps values for two passes of x264 recorded in a text file. I'm using a batch file to launch my x264.exe encode. Is there an easy way to accomplish this? I'm under win32 by the way.

Thanks all.

squid_80
28th August 2007, 03:51
Could do it with a two line batch file:
x264 [options] 2>&1 | tee temp.txt
find "encoded" temp.txt | find "kb/s" > log.txt

temp.txt will have the full log while log.txt will have just the final line from the output.

graysky
28th August 2007, 20:30
@squid: thanks very much for your post... this is exactly the behavior I was looking for!

chros
1st September 2007, 09:26
An addition to squid_80's suggestion: you can get only the fps value not just the whole line.
x264-encode.cmd :

SET infile=%1
SET tempfile=temp.txt

:: "%~n1.mp4" : if infile was 'foo.avs' , then it's 'foo.mp4'
x264 [options...] --output "%~n1.mp4" %infile% 2>&1 | tee %tempfile%

:: it finds the row, which we need (includes 'frames,' string);
:: and splits this at ',' , then it assign the string to 'fps' variable, eg: ' 3.55 fps'
for /f "delims=, tokens=2" %%X in ('type temp.txt ^|find "frames,"') do SET fps=%%X
:: removing all the spaces from the 'fps' variable, eg: '3.55fps'
SET fps=%fps: =%
:: chopping the last 3 chars ('fps'), so we get: '3.55'
SET fps=%fps:~0,-3%

:: it appends to log.txt : '3.55 foo.mp4'
ECHO %fps% "%~n1.mp4" >> log.txt


You can call the batch script with this:
x264-encode.cmd foo.avs