View Full Version : VapourSynth Batch Script Creator
jay123210599
26th October 2024, 13:47
Is there a tool that I can use to make multiple VapourSynth scripts at once?
_Al_
27th October 2024, 02:42
You might not need to create many scripts, because vspipe can load an argument, which in your case would be your source. So you can have only one script saved.
Example running this batch file:
@echo off
set "script=E:\scripts\script.vpy"
set "vspipe=C:\Program Files\VapourSynth\core\vspipe.exe"
set "ffmpeg=E:\tools\ffmpeg.exe"
set "directory=E:\videos"
set "encoded_directory=E:\new"
for %%i in (%directory%\*.*) do call :encode "%%i"
pause
exit
:encode <encoded filepath>
if /i "%~x1"==".ffindex" goto :eof
echo encoding file: %1
"%vspipe%" "%script%" --outputindex 0 --container y4m --arg "source=%~1" - | "%ffmpeg%" -y -f yuv4mpegpipe -i - -c:v libx264 -crf 18 "%encoded_directory%\%~n1.mp4"
goto :eof
and your script.vpy could be (source plugin could be different):
from vapoursynth import core
clip = core.ffms2.Source(source)
clip.set_output()
so vspipe always sets source variable in your script to a filepath, which is specified in batch script : --arg source=%~1
%1 ir your current filepath in that batch script
or specify more what you are doing if this is not working for you ...
_Al_
27th October 2024, 17:43
Also you are a python programmer now using vapoursynth, so this simple python script would batch create scripts for you, if you'd want to go that way,
give this script name "batch_creator.py" and run it:
from pathlib import Path
SCRIPT_TEMPLATE = f"""from vapoursynth import core
source = "{{}}"
video = core.lsmas.LWLibavSource(source)
video.set_output()
"""
SOURCE_DIRECTORY = r'E:\videos'
SCRIPT_DIRECTORY = r'E:\scripts'
sources = Path(SOURCE_DIRECTORY).glob('*.mkv') # loading using wild cards, possible select patterns or extension
for source in sources:
script_path = Path(SCRIPT_DIRECTORY) / f'{source.stem}.vpy'
source = source.as_posix() # to print proper slashes (for windows)
script_text = SCRIPT_TEMPLATE.format(source)
with open(str(script_path), "w") as f:
f.write(script_text)
that would create vapoursynth scripts based on your videos,
you can run this script in any python editor or just as a batch command: python batch_creator.py
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.