Baby's first script
Some basics that might be useful when writing your first script.
Index a video
Available indexers to consider
- bestsource1
The most accurate but slowest indexer. - lsmas2
Fast, mostly reliable enough. - ffms23
With the latest version pretty much on par with lsmas and possibly even faster.
DGIndexNV is also technically something you can use, but recent versions have been buggy and it's restricted to Nvidia GPUs.
DVDs
For DVDs you can skip the following Usage section and simply read the IsoFile
usage section in the vs-source readme.
I've been told dvdsrc
also should set the metadata correctly but ymmv.
Usage
Ensure video metadata
Most functions that resample/resize a video require metadata to be present.
Most videos you download and the majority of BDs are untagged so this is often a necessary step. (And really also just good practice)
Indexing via vs-source
will automatically try to guess via resolution.
Output the clips
Technically all you need is clip.set_output(0)
but vstools/vspreview provide a helper function with more features.
If you want to only output clips when previewing and do other stuff, like encoding with vs-muxtools, you can use the vspreview helper function like this
Other notable stuff
Affinity and memory allocation
Tip
It is highly recommended to at least set the cache size vapoursynth is allowed to use.
This should ideally always be done as the first (non-import) step in your script.
You can set the cache size like this:
Threads and affinity allocation is less "figured out" and may require testing on your individual system.
Some quick testing on a Zen 4 (Ryzen 7000) chip without 3D-VCache suggested that using every other thread for vs and letting the encoder choose by itself is the fastest.
You can set the affinity and cache size like this:
Vanilla VS only allows you to set a number of threads via core.num_threads
.
The vs-tools wrapper also sets the affinity.
This example uses every other thread in the range of 0 - 31. Read more about ranges here.