Avisynth+Avsp=Batch scripts

This forum is for questions and discussion of all the aspects of handling and cleaning up your footage with Avisynth.
Locked
User avatar
Jemm54
Joined: Fri Oct 12, 2007 9:43 am
Status: Cow
Location: Argentina!!
Contact:
Org Profile

Avisynth+Avsp=Batch scripts

Post by Jemm54 » Fri Feb 04, 2011 2:28 pm

Hello guys

I need a little help, im use Avsp, and works great, but now, i wanna create various scripts at same time, a stupidly simple avs, just need the filename and audio=false function, i see the example in the program:

Code: Select all

# This example shows how to automatically generate multiple scripts given a 
# directory with several source files.  Note that this example doesn't even
# directly interact with the AvsP program itself, it's almost entirely using
# pure Python for batch processing, with conviniece gui functions provided by
# the avsp module.

import os

# Get the directory containing source files
dirname = avsp.GetDirectory()

if dirname:
    # Generate each of the avisynth scripts
    for filename in os.listdir(dirname):
        fullname = os.path.join(dirname, filename)
        if os.path.isfile(fullname):
            # Get the extension-based template string
            srctxt = avsp.GetSourceString(fullname)
            # Create the script string
            scripttxt = srctxt + '\n' + 'Sharpen(1.0)\nInfo()'
            # Write the script text to a file
            f = open(fullname + '.avs', 'w')
            f.write(scripttxt)
            f.close()
i tried i a few places, buy allways give me errors, where i have to place the "audio=false", to generate those .avs files, i was reeding something of pyton or something like that, but i dont have idea...

Thanks for reed

Pd: sorry for my bad english XD

Mister Hatt
Joined: Tue Dec 25, 2007 8:26 am
Status: better than you
Contact:
Org Profile

Re: Avisynth+Avsp=Batch scripts

Post by Mister Hatt » Fri Feb 04, 2011 6:37 pm

You realise you need a basic understanding of the python programming language to modify this yes? If it was regular avs, where would you be putting the 'audio=false' string? To be honest, I don't even understand why you need that string, as all the good source plugins don't import audio to start with. Sounds like a case of DSS, you should get that looked at. Also use perl you heathen. If the scripts are so simple, I'd probably just write one, then duplicate it and swap out filenames with sed or a small perl one liner. Easier. Why you gotta be so lazy when the script is this basic?

User avatar
Jemm54
Joined: Fri Oct 12, 2007 9:43 am
Status: Cow
Location: Argentina!!
Contact:
Org Profile

Re: Avisynth+Avsp=Batch scripts

Post by Jemm54 » Fri Feb 04, 2011 7:03 pm

Mister Hatt wrote:.... Sounds like a case of DSS....
Exactly XD Now discover "ffvideosource", and that resolve my problem, like you say, that not import the audio, but im not sure about if i have to set the fps in every script o detects automatically....

Another way to do it i just discover witout pyton is adding the audio function to the import settings in avsp gui

Image

That works to...

So can someone resolve my question about the fps in FFVS, Thanks :wink:

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: Avisynth+Avsp=Batch scripts

Post by Phantasmagoriat » Fri Feb 04, 2011 10:41 pm

It would be easy with a Windows batch file:

Code: Select all

for %%n in (*.*) do (
echo ffvideosource("%%n"^)    >  "%%n.avs"
echo crop(8,0,-8,0^)          >> "%%n.avs"
echo spline36resize(848,480^) >> "%%n.avs"
echo gradfunkmirror(^)        >> "%%n.avs"
echo generic_filter(^)        >> "%%n.avs"
)
-Paste this into a .txt file, and change it to .bat
-Run it in the directory that holds your video files, and it will generate the .avs scripts automatically.
There are other methods too:
http://www.animemusicvideos.org/forum/v ... 45&t=88059
http://www.animemusicvideos.org/forum/v ... 5&t=100151

What do you want the final scripts to look like anyway?
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

User avatar
Jemm54
Joined: Fri Oct 12, 2007 9:43 am
Status: Cow
Location: Argentina!!
Contact:
Org Profile

Re: Avisynth+Avsp=Batch scripts

Post by Jemm54 » Mon Feb 07, 2011 2:53 pm

Phantasmagoriat wrote:It would be easy with a Windows batch file:

Code: Select all

for %%n in (*.*) do (
echo ffvideosource("%%n"^)    >  "%%n.avs"
echo crop(8,0,-8,0^)          >> "%%n.avs"
echo spline36resize(848,480^) >> "%%n.avs"
echo gradfunkmirror(^)        >> "%%n.avs"
echo generic_filter(^)        >> "%%n.avs"
)
-Paste this into a .txt file, and change it to .bat
-Run it in the directory that holds your video files, and it will generate the .avs scripts automatically.
Guau, thanks, thats very useful, buy ill bother you one last time, whats the "code" or wathever, you use to put the filename and fullpath in the case i wanna move the .avs files. Thanks again

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: Avisynth+Avsp=Batch scripts

Post by Phantasmagoriat » Mon Feb 07, 2011 7:37 pm

To use Absolute Paths, you must specify the input location, like "%INPUT%\%%n"
  • In this case I have set the INPUT location as the current directory: %CD%
  • Since we are setting variables, we can set an OUTPUT path too: %CD%\SCRIPTS
  • We can also specify which file TYPES we want to create scripts for: *.mkv *.mp4 *.avi... (*.* is also possible)
When we substitute these variables it looks like this:

Code: Select all

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This .bat code creates .avs scripts for video files  ::
:: in the current directory and places them in a folder ::
:: called SCRIPTS.  To use, simply Paste into a .txt    ::
:: file and change to .bat.  Then run it in the same    ::
:: directory as your video files.  Modify as needed.    ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

SET INPUT=%CD%
SET OUTPUT=%CD%\SCRIPTS
SET TYPES=*.mkv *.mp4 *.avi
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

MKDIR "%OUTPUT%"
for %%n in (%TYPES%) do (
echo ffvideosource("%INPUT%\%%n"^) >  "%OUTPUT%\%%n"
echo crop(8,0,-8,0^)               >> "%OUTPUT%\%%n"
echo spline36resize(848,480^)      >> "%OUTPUT%\%%n"
echo gradfunkmirror(^)             >> "%OUTPUT%\%%n"
echo generic_filter(^)             >> "%OUTPUT%\%%n"
)
CD %OUTPUT%
ren *.* *.avs
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
You can set INPUT/OUTPUT and TYPES as anything now. Since it uses Absolute paths, you can move your scripts anywhere and they should still function correctly. However, the drawback is you can't move the actual video files. That is what Relative Paths are good for.

To use Relative Paths, use a generic location like "..\%%n" instead of "%INPUT%\%%n"
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

Locked

Return to “AviSynth Help”