Log in

View Full Version : Sound Support for VapourSynth Linux


forgetfool
21st March 2021, 09:38
Hi, people.

Just a short history before my question. I have been using AviSynth/AviSynth+ on Windows quite heavily with Audacity being my sound editor and VirtualDub - a renderer. At some point I fully switched to Linux (currently it's ArchLinux).

So I did my research and started using Vapoursynth. One thing I noticed at the time is that Vapoursynth did not have sound support (otherwise works like a charm). So I had to render all clips, then use ffmpeg to overlay them with the combined sound.

Recently I did my research again and on Vapoursynth site it mentions built-in sound support (via a plugin)! But... it seems it is for Windows only: https://forum.doom9.org/showthread.php?t=177623. Am I correct in this?

Trying to use vs.core.damb.Read() seems to have no effect, i.e. at does not attach sound to video, though does not fail either. What would be the reason for that?

Thanks for any help in advance.

fAy01
21st March 2021, 12:45
You should take a look at this thread: https://forum.doom9.org/showthread.php?t=177623

forgetfool
21st March 2021, 15:47
Thanks, but it does not answer either of my questions.

1) I suppose I can infer that BAS is only for Windows

2) I still don't understand why DAMB does not work

jackoneill
21st March 2021, 19:03
Thanks, but it does not answer either of my questions.

1) I suppose I can infer that BAS is only for Windows

2) I still don't understand why DAMB does not work

1) Maybe it's currently available only for Windows, but that should not be the case forever.

2) How do you determine that it doesn't work?

DJATOM
22nd March 2021, 19:40
BAS can be compiled on Linux. I have tested it on my Debian 10 box and it worked.

forgetfool
23rd March 2021, 17:44
Thanks! Do I compile it from here: https://github.com/vapoursynth/bestaudiosource? What is needed for it to compile? There are no instructions there :-)

DJATOM
24th March 2021, 15:54
Hope I'm not missing anything
pip3 install meson
cd bestaudiosource
meson build
ninja -C build

forgetfool
24th March 2021, 19:19
A couple of notes:

1) I found "VapourSynth4.h" (included in "vapoursynth.cpp") only in "doodle1" branch of "vapoursynth/vapoursynth" on git (and manually copied it into /usr/include/vapoursynth/)


2) The source then would not compile with an error:
"../src/vapoursynth.cpp:89:115: error: ‘nfMakeLinear’ was not declared in this scope"

Looking at VapourSynth.h vs VapourSynth4.h, I discovered the following:

typedef enum VSNodeFlags {
nfNoCache = 1,
nfIsCache = 2,
nfMakeLinear = 4 /* api 3.3 */
} VSNodeFlags;

vs

typedef enum VSNodeFlags {
nfNoCache = 1
} VSNodeFlags;

So I copied the corresponding line to "VapourSynth4.h"


3) And the main thing. "libbestsourceaudio.so" got built now, I copied it into /usr/lib/vapoursynth/, but still got a script error:
"No attribute with the name bas exists. Did you mistype a plugin namespace?"

So I tried to load the plugin explicilty by:
vs.core.std.LoadPlugin("/usr/lib/vapoursynth/libbestaudiosource.so")

And the response was "vapoursynth.Error: No entry point found in /usr/lib/vapoursynth/libbestaudiosource.so"


What do I try now?

Thanks

DJATOM
24th March 2021, 21:03
Obviously you can't run APIv4 filter with APIv3 backend. Go all the way to compile doodle1 branch and install it. APIv3 plugins are backward compatible with APIv4 backend, not vice versa.

forgetfool
25th March 2021, 17:55
Better and worse :-)


I still needed to add the line in bold for BAS to compile

typedef enum VSNodeFlags {
nfNoCache = 1,
nfMakeLinear = 4
} VSNodeFlags


BAS now loads, but I get:
File "src/cython/vapoursynth.pyx", line 2542, in vapoursynth.Function.__call__
vapoursynth.Error: Filter Source specified unknown flags


If I don't add the line above, I need to change bestaudiosource/vapoursource.cpp, line 89

from
vsapi->createAudioFilter(out, "Source", &D->AI, 1, BestAudioSourceGetFrame, BestAudioSourceFree, fmUnordered, nfMakeLinear, D, core);

to
vsapi->createAudioFilter(out, "Source", &D->AI, 1, BestAudioSourceGetFrame, BestAudioSourceFree, fmUnordered, nfNoCache, D, core);

since nfNoCache is the only flag available in V4.


Now it even starts rendering for a second, but then exists with the following:

[file] Reading from stdin...
(+) Video --vid=1 (rawvideo 1280x720 24.000fps)
VO: [gpu] 1280x720 yuv422p
V: 00:00:00 / 00:00:00 (67%) Cache: 0.0s

Exiting... (End of file)

(It is a segmentation fault.)



Is this a ffms2 problem now? (If I disable any audio stuff, the problem is still occurring)