Log in

View Full Version : Batch scripting x264 encoding


Blue_MiSfit
30th January 2010, 11:20
Hi all! I've got a simple batch file going here which automatically processes video files.

http://pastebin.com/m1d3b491b

It takes 4 CLI arguments, the first 3 are bitrates and the 4th is the SAR.

This script then runs through the current directory, looking for .avs files, and using these as the source for x264 to output a 264 file.

Then, a muxing perl script runs which takes this 264 file, and produces a TS file from it (per some special hardware specs). The muxing script supports another argument, pointing to an AC3 audio file. So, I will have AC3 files that match the AVS files like this:

movie.avs
movie_audio.ac3

How the heck can I have the script pass this type of file name as an argument to my perl script?

Example command line for muxer:
tsmux_multi3.pl -p h264:movie_1000.264 ac3:movie.ac3 > 1000.ts

I know this script is disjointed. It was originally designed for something a bit different, and I know next to nothing about scripting... so yeah

Help!!

J_Darnley
30th January 2010, 12:54
%%ni_audio.ac3

von_Runkel
30th January 2010, 14:01
The FOR modifiers (type FOR /?). Extremely useful for batch video and audio cmd scripts:


....
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string

The modifiers can be combined to get compound results:

%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line

Blue_MiSfit
30th January 2010, 23:35
Thank you both!!!

Blue_MiSfit
31st January 2010, 00:06
Okay, now for another question.

What if I want x264.exe to start using low priority, in the same proccess window?

http://paste.pocoo.org/show/172025/

If I do this, the process starts at low priority, but then the next task begins while x264 is running, and my muxer doesn't like that very much..

How do I make the batch wait until x264 is done?

~MiSfit

TinTime
31st January 2010, 00:31
Use /wait

So...
start /low /b /wait x264 %%i --level 41 --bitrate %2.......

Blue_MiSfit
31st January 2010, 06:01
Right. start /? would have given me that.

I need to remember that there is documentation on my system about all of this, and that searching is easy!

Thanks!

~MiSfit