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 > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th January 2019, 14:54   #1  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Avs+ and audio ChannelMask

A avs audio decoder can know the ChannelMask and:
Quote:
Originally Posted by TheFluff View Post
FFMS sets the script variable FFCHANNEL_LAYOUT which contains the dwChannelMask. You can get one variable per clip using the varprefix option if you like.
But how can Avs+ export that info to audio output?

1) Let me explain the problem:

We have, for instance, a 3 channel (FL-FR-FC or 3/0/0) 300.dts
And we can recode without problems to a correct 300.ac3 with ffmpeg
ffmpeg -i 300.dts 300.ac3

But using Avs+ with a simple script like:

Quote:
FFAudioSource("D:\tmp\300.dts")
and
ffmpeg -i 300.avs 300.ac3

I obtain:
...
Guessed Channel Layout for Input Stream #0.0 : 2.1
...
And a 2/0/1 or FL-FR-LFE 201.ac3 instead a 300.ac3

Seems than ffmpeg ignore the script variable FFCHANNEL_LAYOUT generated by FFAudioSource
Don't help add OPT_UseWaveExtensible = True (same warning and output)

And also fixing OPT_dwChannelMask:

Quote:
global OPT_UseWaveExtensible = true ## default false
global OPT_dwChannelMask = 7 ## 300 (FL-FR-FC)
FFAudioSource("D:\tmp\300.dts")
The behaviour is the same. The Channel Layout is "Guessed" to FL-FR-LFE

If ffmpeg can't use the AviSynth global OPT or the script variable FFCHANNEL_LAYOUT generated by ffms2.dll how can use them?

2) Workarounds.
I know two interfaces to output correct WAVE_FORMAT_EXTENSIBLE headers from AviSynth with the correct ChannelMask.

2.1) BeHappy
Is enough set [2]Tweak.ChMask to 7 to obtain the correct WAVE_FORMAT_EXTENSIBLE AiSynth output, than can be stored like wav or recoded to any format with FL-FR-FC support, of course to AC3 with ffmpeg.

2.2) Wavi
Now the ChannelMask must be in the command line:

wavi test.avs /M 7 300.wav

Of course can be piped to any encoder like ffmpeg without problems
But the avs can't have global OPT_UseWaveExtensible = true
Wavi can generate the WAVE_FORMAT_EXTENSIBLE header but don't accept it like input:

Error: Could not find PCM audio track in "test.avs".
(However, the file contains an audio track of another format.)

2.3) avs2pipemod
Like wavi avs2pipemod can generate the WAVE_FORMAT_EXTENSIBLE by command line:

avs2pipemod -extwav 300.avs > 300.wav

or other encoder, of course, but we can't put the correct ChannelMask like a parameter an always set a default per numchannels.
Then the avs2pipemod default for 3 channels is FL-FR-BC and we obtain a incorrect 210.wav instead a 300.wav

3) The ChannelMask must be a audio property than replace to NumChannels.
The NumChannels can be obtained very easy from ChannelMask (sum of bits with 1).
In this Century the AviSinth audio output must be always WAVE_FORMAT_EXTENSIBLE with the correct ChannelMask.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 12th January 2019, 23:16   #2  |  Link
goorawin
Registered User
 
Join Date: Feb 2012
Posts: 82
I'm not sure if the Soundout plugin may help solve your problem. It is only in a 32bit version but does work with Avisynth+
http://avisynth.nl/index.php/SoundOut
goorawin is offline   Reply With Quote
Old 13th January 2019, 13:14   #3  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Thanks for the answer.
Soundout can output WAVE_FORMAT_EXTENSIBLE format, but always set ChannelMask (using OPT_dwChannelMask or not) to the invalid value of 0.
Then any encoder can apply the default or show a error.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 16th January 2019, 09:40   #4  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
OPT_UseWaveExtensible and OPT_dwChannelMask only has an effect if the consuming application is using the VFW interface to read data from Avisynth. Anything talking to the Avisynth API directly (so most things these days, since the VFW interface isn't hip anymore) will only see num_channels unless they explicitly go looking for variables in the script environment.
TheFluff is offline   Reply With Quote
Old 16th January 2019, 11:20   #5  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by TheFluff View Post
...unless they explicitly go looking for variables in the script environment.
But like seems than SoundOut, wavi, avs2pipemod and also ffmpeg ignore OPT_dwChannelMask or FFCHANNEL_LAYOUT, there are a way to decode multichannel audio to a correct WAV/W64 with Avs?
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 16th January 2019, 17:23   #6  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by tebasuna51 View Post
But like seems than SoundOut, wavi, avs2pipemod and also ffmpeg ignore OPT_dwChannelMask or FFCHANNEL_LAYOUT, there are a way to decode multichannel audio to a correct WAV/W64 with Avs?
I dunno about that but I took a quick look at avs2pipemod and it doesn't look too difficult to patch it to get it to read OPT_dwChannelMask. It already supports WAVE_FORMAT_EXTENSIBLE.
TheFluff is offline   Reply With Quote
Old 17th January 2019, 10:13   #7  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by TheFluff View Post
... I took a quick look at avs2pipemod and it doesn't look too difficult to patch it to get it to read OPT_dwChannelMask.
That sounds fine, thanks.

Also, how fill OPT_dwChannelMask with FFCHANNEL_LAYOUT provided by FFAudioSource in the avs script?
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Reply

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 20:04.


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