Log in

View Full Version : How to insert FRAMES into x264_x64 command


laserfan
15th May 2011, 21:42
My command line for using x264_x64 with 32bit Avisynth looks approximately like this:
pipebuf.exe avs2yuv.exe video.avs - : x264_x64.exe [options] --output video.264 --frames %FRAMES% --demuxer y4m --stdin y4m --pass 2 - : 4

But to get the FRAMES I first run this
avs2yuv.exe -frames 1 video.avs -o NUL 2>Framecount.txt

and the Framecount.txt result looks e.g. like this:
D:\video.avs: 1920x1080, 24000/1001 fps, 156198 frames

So then I type 156198 into a SET FRAMES= line that calls my command above. But I feel there must be a better way to do this, with either a way to automatically parse the framecount.txt line in my Batch cmd, or use a different method than avs2yuv.exe to give me just the framecount number? Any ideas? :confused:

J_Darnley
15th May 2011, 22:06
Check that this works correctly, then replace echo as needed.
for /F "tokens=5" %A in (file) do echo %A

laserfan
15th May 2011, 22:59
Not at my video PC atm but it looks very promising indeed, thanks for the hint! :)

Loop command: against a set of files - conditionally perform a command against each item.

Syntax
FOR /F ["options"] %%parameter IN (filenameset) DO command

Key
options:

tokens=n Specifies which numbered items to read from each line
(default = 1)

laserfan
16th May 2011, 21:01
Check that this works correctly, then replace echo as needed.
for /F "tokens=5" %A in (file) do echo %AThanks again JD, this appears to work perfectly for me:

REM Get FRAMES variable
FOR /F "TOKENS=5" %%F IN (D:\%LOCATION%\Framecount.txt) DO @SET FRAMES=%%F
:thanks: