A avs audio decoder can know the ChannelMask and:
Quote:
Originally Posted by TheFluff
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.