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. |
2nd July 2015, 07:03 | #1 | Link |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
AviSynth behavior for redundant commands
In the past I have learned that for example the command "ConvertToYV12()" will be completely ignored if the clip already has this color space. Very nice because I can freely use this command without having to know the color space of the source.
Now what about some audio conversion commands? Will "ConvertAudioTo24Bit()" do anything if audio already is 24bit? What about "ResampleAudio(xxxx)" or "SSRC(xxxx)" if the clip already has this sample rate? Cheers manolito |
2nd July 2015, 07:18 | #2 | Link | |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
AviSynth 2.6:
Quote:
Both of them output float, so there will be a change unless input is also float. Which I think should not happen, i.e. might be considered a bug. |
|
2nd July 2015, 09:43 | #3 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
So if the target rate is the same as the original rate, the function is a no-op for 16-bit input. |
|
2nd July 2015, 10:31 | #5 | Link |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Thanks a lot guys, very helpful...
The reason I was asking is my Wavi_Mod plugin for AVStoDVD which enables alternative methods for audio normalizing (SoX, EBU R128, DynamicAudioNormalizer). It uses either pipes or temp files, and I figured it could be useful to generally employ 24bit integer intermediate WAVE files. LAV audio is used as the source filter, and it mostly decodes as 32bit float (unless the user has disabled some output formats). But the Wavi output is always integer, probably because AVStoDVD is written in VB6 which probably uses AviSynth through the VfW interface which does not support float. So my idea is to always append "ConvertAudioTo24Bit" to the end of the AviSynth script. This should make sure that no precision is lost when the format would be 32bit float like after SSRC. (Got this from an older post from Gavino). Does this sound reasonable? Or is it just a waste of time since the final format will be AC3 ? Thanks again manolito Last edited by manolito; 2nd July 2015 at 10:34. |
2nd July 2015, 10:37 | #6 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
I don't understand what you're trying to achieve. How is adding an additional conversion at the end of a chain making sure no precision is lost? There are only three cases:
1. input into ConvertAudioTo24Bit() is 16 bit: will be skewed to 24 bit, no additional precision, just a useless conversion 2: input into ConvertAudioTo24Bit() is 24 bit: no change 3: input into ConvertAudioTo24Bit() is 32 bit integer or float: loss of precision |
2nd July 2015, 13:16 | #7 | Link | ||
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Quote from tebasuna:
Quote:
Quote:
In AVStoDVD you can never know in advance which bit depth Wavi will get from AviSynth. If the input from LAV audio is 32 bit float or if SSRC() is used within AviSynth, the Wavi output will be 16 bit integer. In these cases forcing 24 bit integer makes sense IMO. Your three cases: 1. Useless yes, but at very low cost in terms of speed. 2. Yes 3. Since float is not supported and would normally get converted to 16 bit integer, forcing 24 bit integer should (almost) preserve the precision according to tebasuna. Of course I could first analyze what Wavi would output without interfering and then decide if I need to force 24 bit integer, but why should I do this if forcing 24 bit no matter what has no disadvantage? Cheers manolito |
||
2nd July 2015, 17:05 | #9 | Link | ||
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Quote:
Quote:
Do you think that SoundOut or ffmpeg would do a better job? And there is another requirement: The tool must support large WAVE files > 4GB. I am not talking about WAV EXTENSIBLE or WAV 64 since these formats are not supported by SoX and Aften. I would need the standard WAV format (but larger than the standard allows). No problem for Wavi... Cheers manolito Last edited by manolito; 2nd July 2015 at 17:15. |
||
2nd July 2015, 18:01 | #11 | Link | |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Thanks for the suggestion...
Had a quick look at it, but compared to Wavi the capabilities are overkill, and here's the showstopper: Quote:
So I will stick with Wavi... Cheers manolito |
|
2nd July 2015, 19:14 | #13 | Link | |
...?
Join Date: Nov 2005
Location: Florida
Posts: 1,420
|
At least the way I'd understand it, AVStoDVD *should* be passing the script to the particular programs (where applicable), therefore whatever the program does to access AviSynth would matter more than whether AVStoDVD itself might use the VfW interface to talk to scripts. For FFmpeg this would mean accessing the library directly and - if using -acodec copy - getting out exactly whatever the audio format output from the script is.
Code:
ffmpeg -i input.avs -acodec copy output.wav Quote:
For Aften, you can work around this using qaac as a passthrough: Code:
ffmpeg -i test.avs -acodec copy -f wav - | qaac --silent -D - -o - | aften - output.ac3 SoX and Aften do support WAVE_FORMAT_EXTENSIBLE, but not when piped by FFmpeg (this is discussed in this thread - the short version: some programs don't like the way FFmpeg writes the WAVE headers when piping). A standalone file with an extensible header does work, although I was testing with 30-second samples. An alternative is to force FFmpeg to use a different format to pipe to SoX. WavPack works (and from how the docs read, the native libavcodec wavpack encoder only does lossless): Code:
ffmpeg -i test.avs -acodec wavpack -f wv - | sox -t wv - output.wav Although as sneaker_ger pointed out, avs2pipemod seems to handle this correctly without resorting to qaac passthrough tricks or using alternative pipe formats. |
|
3rd July 2015, 04:22 | #14 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
Yes, looks like it. So for the sake of completeness avs2pipemod's WAVEFORMATEXTENSIBLE:
avs2pipemod -extwav input.avs | SoX -t wav - output.wav I also remember having trouble with ffmpeg->sox pipes now that you mention it. I think Hybrid uses headerless PCM piping for that reason. |
3rd July 2015, 07:43 | #15 | Link |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Thanks guys,
you gave me a couple of ideas to rewrite my plugin to use the extensible wave format exclusively. AVStoDVD can already use ffmpeg to extract a wave file from the avs script, but the wave is always 16 bit int. Took me a while to find out that the reason for this is that "-acodec copy" is missing from the command line. Wavi always extracts 16 bit int wav files when the format is 32 bit float (even though the changelog says that it supports float). Cheers manolito |
6th July 2015, 08:06 | #16 | Link | |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
Quote:
Is a AviSynth default than need be canceled with, for instance in a test.avs: global OPT_AllowFloatAudio=True # enables WAVE_FORMAT_IEEE_FLOAT audio output. NicAc3Source("D:\tmp\200.ac3") # Decoder output is 32 bits float And: wavi test.avs output.wav Found PCM audio: 2 channels, 48000 Hz, 32 bits, Audio track contains floating-point samples. EDIT: Other soft like MeGUI or BeHappy don't need 'global OPT_AllowFloatAudio=True' because a special AvisynthWrapper.dll
__________________
BeHappy, AviSynth audio transcoder. Last edited by tebasuna51; 6th July 2015 at 08:14. Reason: add info |
|
6th July 2015, 13:11 | #17 | Link |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Thanks very much Tebasuna...
I did not even know that this AviSynth command even existed. Question: Why is this command only needed for Wavi, but not for ffmpeg and avs2pipemod? And since I'm at it: What is your opinion on the preferred intermediate WAV resolution for DVD audio conversion (I am not talking about professional audio recording and mixing/mastering). I did quite a lot of reading about this topic in the audio forums, and there are different opinions. Most people say that 24bit int is more resolution than anyone will ever need, others say that the better clipping protection which float offers is indeed worth the trouble. Cheers manolito |
6th July 2015, 13:37 | #18 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Manolito,
OPT_AllowFloatAudio, occurs @ Avisynth Syntax/Internal Functions/Control Functions, in Avisynth built-in docs, with a few more 'secret' bits and pieces. EDIT: Or here on wiki:- http://avisynth.nl/index.php/Interna...llowFloatAudio
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 6th July 2015 at 13:46. |
6th July 2015, 18:20 | #19 | Link |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Thanks for the tips,
just tried it with several sources, it works, but only if the global OPT_AllowFloatAudio=True comes at the beginning of the AVS script. I first tried to append the command to the end of the script (after the "audiodub(video,audio)" command), but this did not work. Wavi would then complain that no PCM audio could be found at all. //EDIT// The global OPT_AllowFloatAudio=True does not need to be at the very beginning of the script, but it does need to come before the "audiodub(video,audio)" statement. And it also works if the "global" is omitted. Cheers manolito Last edited by manolito; 7th July 2015 at 07:59. |
19th July 2015, 20:23 | #20 | Link |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Bumping this thread because the global OPT_AllowFloatAudio=True command does not work as expected for me...
From the ALLOW I assumed that the audio output will be float only if the source filter delivers float samples. But instead the command seems to FORCE float audio no matter what. I disabled all audio formats except 8bit int in the LAV Audio settings. The LAV status window correctly reports the input format as 32bit float aac and the output format as 8bit int PCM. But with the "global OPT_AllowFloatAudio=True" present in the AVS script the audio output from AviSynth is 32bit float. This means that AviSynth actively converts 8bit int audio samples as delivered by the source filter to 32bit float - which of course does not make much sense. Can anyone confirm this behavior? Cheers manolito |
|
|