PDA

View Full Version : Filter once, output x times


ChaosKing
7th January 2017, 17:48
There is a avisynth plugin called TwriteAvi, which can save the current output from line x in a script.

If it is put at the end one can encode for example a lossless file and a x264 video in parallel. The advantage here is, that the filters are processed only once for each output. It's very usefull for very slow scripts.


Is something similar possible with vapoursynth? Maybe with some python magic? :)

poisondeathray
7th January 2017, 18:01
couldn't you use vspipe to ffmpeg ? ffmpeg can export multiple outputs . So one output branch might use ffmpeg libx264 , another might use ut video, a third might be resized libx264 version etc....

https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs

ChaosKing
7th January 2017, 18:18
That's nice, but I use a modded x264. So a more generic approach would be better.

feisty2
7th January 2017, 19:37
get_read_array and "file" related functions in Python
Everything you need

Myrsloik
7th January 2017, 19:41
That's nice, but I use a modded x264. So a more generic approach would be better.

Exactly what do you need to output to? That's the real question.

ChaosKing
7th January 2017, 21:05
It depends, usually I use lagarith or utvideo for 8bit and x264 -q 0 for 10bit lossless encodes. After that lossy x264 or x265.

TheFluff
9th January 2017, 02:28
I don't care what your opinions on functional programming languages are, VS and Avisynth filter chains are both by their natures effectively almost purely functional environments. For a pleasant experience, go with the flow, do as the Romans do and please resist digging into StainlessS' infinite toolbox of bad ideas. That means, stop considering "make frame requests have side effects" a reasonable solution to a problem - any problem at all.

Now, the problem you're trying to solve is absolutely trivial in nature - you just want to duplicate your output to feed two different consumers. This was obnoxious in Avisynth in 2005 (or whenever TWriteAvi originates) because the only possible way to produce output was through the arcane mechanics of VfW (or by using the API directly), but even then it was not at all unsolvable. Today we thankfully use a far simpler and more portable I/O mechanism - pipes - which comes with a huge ecosystem of tools, so let me introduce you to tee (https://en.wikipedia.org/wiki/Tee_(command)), which does exactly what you want. If you're on Unix you can feed both processes directly (see the examples provided here (https://www.gnu.org/software/coreutils/manual/html_node/tee-invocation.html)) but on Windows I think you might have to set up a named pipe. Not sure though, I'm not a PowerShell expert, so I leave figuring that out as an exercise to the reader.

e: if you want the output somewhere in the middle of the filter chain, you can output, tee off an encoder, and pipe the other stream back into a new VS environment. Won't be particularly efficient for several reasons but it'll get you there without having to write the I/O and keeping track of which frames have been requested and in what order in Python.

StainlessS
9th January 2017, 02:51
You pontificate way too much.