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. |
19th July 2015, 21:13 | #21 | Link | |
Moderator
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
|
Quote:
Code:
// Allow WAVE_FORMAT_IEEE_FLOAT audio output bool AllowFloatAudio = false; try { AVSValue v = env->GetVar("OPT_AllowFloatAudio"); AllowFloatAudio = v.IsBool() ? v.AsBool() : false; } catch (IScriptEnvironment::NotFound) { } filter_graph = return_val.AsClip(); if (!AllowFloatAudio && filter_graph->GetVideoInfo().IsSampleType(SAMPLE_FLOAT)) // Ensure samples are int filter_graph = env->Invoke("ConvertAudioTo16bit", AVSValue(&return_val, 1)).AsClip(); filter_graph = env->Invoke("Cache", AVSValue(filter_graph)).AsClip(); filter_graph->SetCacheHints(CACHE_GENERIC, 999); // Give the top level cache a big head start!! |
|
15th September 2015, 03:49 | #24 | Link | |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Bumping this thread because I found some interesting AviSynth peculiarities:
Quote:
If my source is 32bit float and I use the command "ConvertAudioTo32Bit" then AviSynth will convert the audio to 32bit int. Another item is the command "ConvertAudioToFloat()". The docs only say that the input gets converted to float, leading me to believe that the bit depth will not be altered. But in reality the command always converts any input to 32bit float, no matter what the source bit depth is. Of course this makes sense, even though 16bit float and 24bit float are valid digital data formats, they are are just not used for digital audio samples. But I think that the AviSynth documentation should be clearer about this. And finally something I have no explanation for: Somehow I ended up with the following audio conversion: 32bit float -> 32bit int -> 32bit float (using "ConvertAudioTo32Bit" and "ConvertAudioToFloat" on a 32bit float source) A big waste of time, but IMO it should not hurt the audio. But this conversion changes the volume of the source up to 4dB depending on the source characteristics (the resulting volume will be lower). How in the world can this happen? Cheers manolito |
|
15th September 2015, 11:39 | #25 | Link | |||
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
Quote:
Take in mind than convert 24 to 16 bits int you lose the 8 less significant bits and can't be recovered. Quote:
A 32 bits float sample have 8 bits for coeficient and 24 bits for mantissa, the precision is, more or less, the same than 24 bits int. Quote:
All audio with float samples over 0dB must be Normalized before convert to int samples or encode.
__________________
BeHappy, AviSynth audio transcoder. |
|||
15th September 2015, 13:03 | #27 | Link | ||
Moderator
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
|
Yes it is. See http://avisynth.nl/index.php/Float.
Quote:
edit Quote:
Last edited by Wilbert; 15th September 2015 at 13:20. |
||
15th September 2015, 16:07 | #28 | Link | ||
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
Quote:
Quote:
One other thing about the volume change when converting 32float to 32int and back to 32float: When I analyzed the conversion result and compared it to the source, the RMS volume and also the BS1770 LUFS was a few dB lower than the source, but the sample peak level was the same in both cases (a slightly positive value). Strange... Cheers manolito |
||
15th September 2015, 20:30 | #29 | Link |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
If someone is interested to reproduce my findings, I just uploaded a test archive with the relevant files (160MB):
http://www59.zippyshare.com/v/tAuCf3Cj/file.html How I tested: I used DirectShowSource with LAVFilters 0.65. In LAV audio I checked all output formats so LAV delivered 32bit float samples to AviSynth. The LAV mixer was disabled (no clipping protection active). I used the following script: Code:
global OPT_AllowFloatAudio=True DirectshowSource("i:\test.mpg") # ConvertAudioTo32Bit() # ConvertAudioToFloat() The second file has an audible lower volume than the first one. I got the numbers from a Global Analysis in WaveLab. Here are the pictures from WaveLab: Note the positive peak values for the first file, and also the 3dB difference in the RMS value for the files. Again my question: How can this happen? Converting from float to int might introduce clipping (if you don't normalize first), but it should not alter the volume. Cheers manolito Last edited by manolito; 15th September 2015 at 20:55. |
|
|