Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th October 2024, 13:47   #1  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 385
VapourSynth Batch Script Creator

Is there a tool that I can use to make multiple VapourSynth scripts at once?
jay123210599 is offline   Reply With Quote
Old 27th October 2024, 02:42   #2  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 372
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:
Code:
@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):
Code:
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 ...

Last edited by _Al_; 27th October 2024 at 03:03.
_Al_ is offline   Reply With Quote
Old 27th October 2024, 17:43   #3  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 372
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:
Code:
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

Last edited by _Al_; 27th October 2024 at 17:46.
_Al_ is offline   Reply With Quote
Reply

Tags
scripts, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.