View Full Version : Auto Generating .avs per each video file
DarkT
19th August 2011, 20:47
Hi,
I was looking at the script at: "http://forum.doom9.org/showthread.php?t=75610&page=2"
But couldn't really deconstruct it.
Imagine a .txt file with names of files - each file name per 1 line
example:
acs.mkv
abc.avi
arr.mp4
Now, I need a "script" to automatically generate acs.avs, abc.avs, arr.avs.
Each needs to contain the same script
Say:
DirectShowSource("acs.mkv")
...
...
...
Could somebody help me with that?
Thanks.
johnmeyer
19th August 2011, 21:27
I've used this:
ScriptWriter (http://forum.doom9.org/showthread.php?t=98648)
Perhaps it will do what you want.
hanfrunz
19th August 2011, 21:33
You could use a "simple" script language like python or a basic compiler like freebasic to write a little helper tool. Would be a nice project to learn it :-)
naoan
19th August 2011, 21:39
I usually use this http://www.videohelp.com/tools/AviSynth_Batch_Scripter
It's kinda old but effective nonetheless.
J_Darnley
19th August 2011, 22:56
FOR /F %A IN (file.txt) DO echo DirectShowSource^("%~A"^) > "%~nA.avs"
If you want more than just one line, using a batch file is easier, but not necessary.
DarkT
20th August 2011, 00:22
Wow! lots of kickass solutions. I tried though the program, and it seeeeemed like what I wanted(avisynth batch scripter). I will test it out and let you guys know how it went.
1 more quick thing though, related to the topic:
I also have another thing I need to do:
I have this line:
"C:\Users\Alon\AppData\Roaming\Yamb\MP4Box.exe" -single 1 "X:\a\bbc 1.mp4"
I have a list of 60 filenames - like "bbc 1.mp4" and "cnn 3.mp4" - which I need to apply the whole proccess too.
Any short line for that, J_Darnley?
Basically, in the example there's "bbc 1.mp4" I need the name to be taken out of listofnames.txt and with each file name in the list, a file generated, with the example line, and the filename changed in it - accodring to the listofnames.txt
Though, I think that's achievable with the python script stephen gave... with some modifications... prolly... mhmhmh, I installed python, but it's late at night, dont wanna mess around right now coz' my head dont work too well at the moment. ;).
Edit:
Stephen, your script requires modification for each new file, yes? The original idea was that there's a .txt file containing all the names, 1 name per line. Then the script opens that .txt file, and creates each .avs file with the name from the .txt names file inserted into the "directshowsource" command, the filename outputted as the .avs file would also have teh same name as it had taken from the .txt file.
Ok here's example:
FileNames.txt:
1.mkv
asd.mp4
the script produces, after being ran produces these 2 files:
1.avs:
DirectShowSource("1.mkv")
asd.avs:
DirectShowSource("asd.mp4")
Though, I wanna have more then 1 script line...
BUT... I suppose this is not realllly relevant since I think AvisynthScriptCreator can pretty much do this. I think.
BUT - if you did make such a script, I could modify it to produce another thing I do need, which I talked about in this post. with the mp4box thingy. ANYWAY - MUCHO GRASSIAS man ;). And to the rest of you guys who are contributing as well :).
ajp_anton
20th August 2011, 00:24
It's also possible to have the same script in each .avs file that will use its own filename for the directshowsource filename.
Can't remember how to do it, maybe someone else knows?
So just make one .avs file and copy that into multiple filenames without having to edit the contents of them.
Gavino
20th August 2011, 01:09
It's also possible to have the same script in each .avs file that will use its own filename for the directshowsource filename.
Can't remember how to do it, maybe someone else knows?
In v2.60, you can get the script filename via ScriptName() or ScriptFile() (http://avisynth.org/mediawiki/Internal_functions/Script_functions).
Prior to that, there is a hack using try/catch and examining the error message string. See here.
blis
20th August 2011, 02:15
I use VBscript to generated XML usingMediaInfo. From there I query the XML for audio and video codecs, framerates, aspect ratio and other relevant media parameters and then write to disk the AVS I want including loading plugins etc.
Then feed the avs into ffmpeg as a cmd line run.
J_Darnley
20th August 2011, 09:56
I also have another thing I need to do:
I have this line:
"C:\Users\Alon\AppData\Roaming\Yamb\MP4Box.exe" -single 1 "X:\a\bbc 1.mp4"
I have a list of 60 filenames - like "bbc 1.mp4" and "cnn 3.mp4" - which I need to apply the whole proccess too.
Any short line for that, J_Darnley?
You can't work that out either?
FOR /F %A IN (file.txt) DO "C:\Users\Alon\AppData\Roaming\Yamb\MP4Box.exe" -single 1 "%~A"
Basically, in the example there's "bbc 1.mp4" I need the name to be taken out of listofnames.txt and with each file name in the list, a file generated, with the example line, and the filename changed in it - accodring to the listofnames.txt
I don't understand what you want to do here.
DarkT
20th August 2011, 15:55
You can't work that out either?
FOR /F %A IN (file.txt) DO "C:\Users\Alon\AppData\Roaming\Yamb\MP4Box.exe" -single 1 "%~A"
I don't understand what you want to do here.
The script you wrote would prolly work excellent, but it stops when thre's a "space" in the file name, so the "%~A" part only gets the file name up to the point where there's a space. Otherwise I'm sure that's exactly what I wanted.
If you can make it work, it'd be great.
And no - sorry - couldn't work it out, I'm not big on Dos batch programming. I can do the simple stuff, but I never really learned anything deeper then your simple day to day stuff. NC5 *grins* Norton Commander FTW *grins*
Edit:
BAsically, it seems that %A stores the "filename" as far as the first space. And then, pastes it in the %~A as a tiny part of the entire filename, which messes it up :(
J_Darnley
20th August 2011, 21:16
Oh, my bad. The parsing of the text file will make it ignore things after a space.
Put the following after the /F: "delims="
DarkT
20th August 2011, 21:21
Oh, my bad. The parsing of the text file will make it ignore things after a space.
Put the following after the /F: "delims="
Hehehe, will do.
I hadn't had the patience, so I went ahead and used a program given by a dude in this thread, and created like 70 .bat files... Then I ran them all together lol, still running *grins* so slow... lol, not my wisest move, but hey, it's amusign as hell to have a shitload of cmd windows (well, not 70 at the sme time, I am doing them by portions of 20 hehehe)
Your script however will help in a shitload of other tasks, since, I have ltos of similar grunt work to do, I really should learn some sort of script-programming language... like python, or perl or just plain old dos command prompt batch progrmamming...
Anyway, thanks guys! seriously, you saved me a shitload of time, like ctrl+c ctrl+v time... which is SLOwww time lol.
Edit:
I was just going to say how cool the script worked, and then it all got fucked up! Appearantly BeSweet doesn't like ti when you turn on winamp lol!!! hahahaha, I used your script liek this:
FOR /F "delims=" %A IN (file.txt) DO "C:\Program Files (x86)\BeLight\BeSweet.exe" -core( -input "X:\media\%~A" -output "X:\media\%~A.m4a" ) -azid( -s stereo -c normal -L -3db --maximize ) -bsn( -abr 96 -aacprofile_lc ) -ota( -hybridgain )
the files come out as .ac3.m4a lol, but I don't mind, that's something I can fix myself with ren in cmd I think. Anyway, I turned on winamp and bam! Sync issues and besweet stops responding, I turn it off and bam, all is well again hahahahaha, amusing.
anyway, cool. I got 60 files requiring that - I'l put it for the night, will be cool.
Well this is weird, now this error popped up again: "stream error: sync found after:"
Stranmgely enought, I did do it once with the script, and it ocmpleted just fine... Why it does problems now I do not know... I was opening sites, mayeb oen had audio, which played, and somehow that affected it... I do not know, weird.
Edit:
I get why besweet does errors... Appearantly it does not like .dts *grins* shit... now I need to find a different program to do dts I suppose... *sighs*
J_Darnley
21st August 2011, 11:46
FOR /F "delims=" %A IN (file.txt) DO "C:\Program Files (x86)\BeLight\BeSweet.exe" -core( -input "X:\media\%~A" -output "X:\media\%~A.m4a" ) -azid( -s stereo -c normal -L -3db --maximize ) -bsn( -abr 96 -aacprofile_lc ) -ota( -hybridgain )
the files come out as .ac3.m4a
That's because you using %~A which is replaced by the everything in A (including the extension). This is why I had %~nA which is replaced by just the filename.
The docs for this can be found in Windows' own help files (try searching for "a-z") or see the help output from FOR /?
SSH4
21st August 2011, 12:10
try stickboy's GetSystemEnv() plugin
comand line like this: for /L %a in (1,1,10) do set name=%~na.avs && "c:\Program Files (x86)\ffmpeg\bin\ffplay.exe" 1.avs
script like this:
BlankClip()
Subtitle(GetSystemEnv("name"))
Gavino
21st August 2011, 14:32
try Gavino's GetSystemEnv() plugin
Actually, it's stickboy's plugin:
http://avisynth.org/stickboy/GetSystemEnv.zip
henryho_hk
23rd August 2011, 05:40
for %A in (*.mp4 *.mkv *.avi) do echo directshowsource^("%~sfA"^) > "%~nxA.avs"
Or, if you are 100% sure that you won't be having different video type having the same name....
for %A in (*.mp4 *.mkv *.avi) do echo directshowsource^("%~sfA"^) > "%~nA.avs"
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.