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. |
11th June 2017, 14:40 | #22 | Link |
Guest
Posts: n/a
|
That works. Thanks! The downmix sounds nice.
I dislike GUIs and am happier writing a script (or quickly adapting an existing one, as is usually the case). Most of the time, I decode my audio with eac3to and can pick my output format, so only rarely do I have cause to create individual WAVs. I appreciate your writing a downmix function though. I'm sure it will come in handy at some stage. :-) |
2nd August 2018, 21:06 | #23 | Link |
Registered User
Join Date: Jun 2002
Location: Greece
Posts: 242
|
After reading carefully the previous posts, i decided to make my own script to convert from 5.1 channels to plain stereo (without LFE) and i want your opinion.
fl = WavSource("L.wav").ConvertAudioToFloat() fr = WavSource("R.wav").ConvertAudioToFloat() c = WavSource("C.wav").ConvertAudioToFloat() sl = WavSource("SL.wav").ConvertAudioToFloat() sr = WavSource("SR.wav").ConvertAudioToFloat() # For sg, i consider the values between 0.707 and 1.0 reasonable. left = MixAudio(fl, sl, 1.0, sg).SoftClipperFromAudX(0.0) # reduce volume only if clip is detected right = MixAudio(fr, sr, 1.0, sg).SoftClipperFromAudX(0.0) # reduce volume only if clip is detected # For cg, i think the maximum value should be 0.707, because the acustic power is the square of the amplitude. --> Edit: the minimum value should be 0.707. <-- (0.707 x 0.707) + (0.707 x 0.707) = 0.5 + 0.5 = 1. leftc = MixAudio(left, c, 1.0, cg) rightc = MixAudio(right, c, 1.0, cg) # Stereo (Maybe we need attenuate or amplify) mix = MergeChannels(leftc, rightc) # Check for overflows and RMS values, with SoundOut plugin # SoundOut(mix) # Final stage Normalize(mix) # 0dB # or # Normalize(mix, 0.89125) # -1dB # or # AmplifydB(mix, ...)
__________________
Greece PAL User... Last edited by Nikos; 3rd August 2018 at 13:35. Reason: Correction to the cg value |
2nd August 2018, 23:48 | #24 | Link | |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
|
@Nikos... There are many ways to make a stereo downmix out of a 5.1 surround, many people generally use Dolby Pro Logic II, like so:
Quote:
|
|
2nd August 2018, 23:53 | #25 | Link |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
The standard Downmix uses sg = 1 and cg = 0.707.
In my opinion sg can be lower, but cg can't be lower to preserve dialog volume. The big difference in your method is include the SoftClipperFromAudX() in the first mix. I'm not sure about that, I use SoftClipperFromAudX() in 7.1 -> 5.1 mixing back and side channels not so important than front channels. But if work for you...
__________________
BeHappy, AviSynth audio transcoder. |
3rd August 2018, 02:07 | #26 | Link |
Registered User
Join Date: Jun 2002
Location: Greece
Posts: 242
|
Thank you guys for the answers.
I understand that sg can be lower, I think that sg = 0.707 is reasonable and we are in line with the ITU-R BS.775-3 recommendation. I encode old movies with 5.1 audio and the surround channels are mostly empty. The SoftClipperFromAudX(), it's not critical and work for me I'm more interested in the center channel. In a test, Ι did in "The Good, the Bad and the Ugly" with the above script (sg=1.0 and cg=0.707), Ι had to add AmplifydB(mix,-3.61) to avoid overflows, while with sg=0.707 and cg=0.707, Ι had to add AmplifydB(mix,-3.23). I need a clarification about cg: With cg=0.707 we have all the acoustic power of the center channel. Why we have to increase the cg beyond 0.707? (Unless it is a badly made film) Which value range is acceptable?
__________________
Greece PAL User... Last edited by Nikos; 3rd August 2018 at 02:15. |
3rd August 2018, 08:47 | #27 | Link | ||
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
Quote:
To downconvert to stereo is safe (we don't lose audio info) ignore the surround channels and use only the front channels (your second mix). Quote:
__________________
BeHappy, AviSynth audio transcoder. |
||
3rd August 2018, 13:11 | #28 | Link |
Registered User
Join Date: Jun 2002
Location: Greece
Posts: 242
|
@tebasuna51 thank you for the clarifications.
You are right in everything The cg value can't be lower than 0.707 to preserve dialog volume. Another question: Is there any reason to add to the script: Global OPT_UseWaveExtensible = true and or Global OPT_dwChannelMask = ("0x00003") # for stereo
__________________
Greece PAL User... |
4th August 2018, 13:02 | #30 | Link |
Registered User
Join Date: Jun 2002
Location: Greece
Posts: 242
|
After readind this page about decibel, Ι have a technical question:
Does the AmplifydB(sound, -3) line in Avisynth script, reduce the amplitude or acoustic power of the sound in half?
__________________
Greece PAL User... |
4th August 2018, 19:43 | #32 | Link |
Registered User
Join Date: Jun 2002
Location: Greece
Posts: 242
|
Thank you very much for the answers you give me.
But... new day, new idea... For old movies where the back channels are mostly empty, I can just encode the three front audio channels and during playback I can adjust the level of the dialogs with lav filter or ffdshow. For example: global OPT_dwChannelMask = ("0x00007") audio = WavSource("5.1.wav") GetChannels(audio, 1, 2, 3) What is your opinion? I did a test and in the resulting .wav file, the MediaInfo reports 3 channels but not Channel positions Front: L C R. But in the resulting .m4a file from BeHappy, the MediaInfo reports 3 channels and Channel positions Front: L C R. Edit: With the help of the ChMask=7 in BeHappy, the 3 channels .wav have Channel positions Front: L C R.
__________________
Greece PAL User... Last edited by Nikos; 5th August 2018 at 15:19. |
5th August 2018, 20:38 | #33 | Link | |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
It's ok if you want preserve 3 channels, but some audio systems can have problems with multichannel.
Quote:
BeHappy have a special AvisynthWrapper.dll to write the wav header WAVE_FORMAT_EXTENSIBLE with the selected chMask.
__________________
BeHappy, AviSynth audio transcoder. |
|
5th August 2018, 22:26 | #34 | Link |
Registered User
Join Date: Jun 2002
Location: Greece
Posts: 242
|
I used the BeHappy.
Without ChMask=7, the resulting .wav file, reports 3 channels but not Channel positions Front: L C R. With ChMask=7, the resulting .wav file, reports 3 channels and Channel positions Front: L C R. Is there a manual way, to write the wav header WAVE_FORMAT_EXTENSIBLE, with the help of AvisynthWrapper.dll? I can not find information about using it within an .avs script. Ιt's part of ΒeΗappy source code? I know that I can add the header, with the help of wavfix. Today I did a test: 1. I converted a 5.1 DTS Master Audio sound, from an old movie to 3.0 (Front) .wav, 5.0 (Front+Back) .wav and 5.1 (Front+Back+LFE) .wav. 2. I coded the above three .wav files, with Nero AAC (-lc -q 0.60). 3. The results: 3.0 .acc --> 360 kb/s # normal 5.0 .aac --> 552 kp/s # normal 5.1 .aac --> 553 kp/s # ? It seems strange to me the last result, I was expecting more than 553 kp/s. I coded the LFE channel alone and the the resulting .aac have 10 kb/s!!! Thank you for your support for so many years
__________________
Greece PAL User... Last edited by Nikos; 6th August 2018 at 00:26. |
6th August 2018, 10:16 | #35 | Link |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
The ChMask is the most important field than add the WAVE_FORMAT_EXTENSIBLE header.
In BeHappy the header WAVE_FORMAT_EXTENSIBLE is used when the ChMask (in Tweak section) is activated. And yes is part of BeHappy code. If ChMask is let to 0 value a default is used for number of channels (like wavfix): Code:
Chan. Mask hex-dec MS channels ordered Description ----- ------------ ----------------------- ----------------------- 1 0x0004 4 FC Mono 1/0.0 2 0x0003 3 FL FR Stereo 2/0.0 3 0x0007 7 FL FR FC Stereo + Center 3/0.0 4 0x0033 51 FL FR BL BR Quadro 2/2.0 5 0x0037 55 FL FR FC BL BR Dpl II 3/2.0 6 0x003F 63 FL FR FC LF BL BR Standard 5.1 3/2.1 7 0x013F 319 FL FR FC LF BL BR BC With Back Cent. 3/3.1 8 0x063F 1599 FL FR FC LF BL BR SL SR Standard 7.1 3/2/2.1 The LFE (Low Frequency Effects) have only very low frequencies (filtered by DTS Master Audio) and most the time is empty in old movie sound tracks. A VBR (Variable BitRate) encode (like Nero -q 0.60) need only a very low bitrate to add that channel. Big bitrate is only needed for high frequencies.
__________________
BeHappy, AviSynth audio transcoder. |
18th August 2018, 13:10 | #37 | Link | |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
The ChMask is a problem for Avisynth, like I say to IanB (Avisynth 2.6 developer) long time ago, and to Avs+ developers recently, the ChMask must be a audio property replacing NumChannels (NumChannels can be obtained from ChMask only adding the bits).
The Global variables: global OPT_UseWaveExtensible = true global OPT_dwChannelMask = $7 are ignored or rejected (Wavi), and I don't know any soft than use them. The ChMask by default for 3 channels audio is 3.0 ($7 or FL FR FC) for Wavi, avs2pipemod or BeHappy, but for ffmpeg is 2.1 ($11 or FL FR LFE), you can't create a AC3 3.0 directly with the .avs and ffmpeg: Quote:
But if you have a not standard ChMask the Global variables are useless, and you need BeHappy or Wavi to specify the correct ChMask manually.
__________________
BeHappy, AviSynth audio transcoder. Last edited by tebasuna51; 18th August 2018 at 13:17. Reason: add info |
|
Tags |
configuration, dts-hd ma, merge channels, truehd |
|
|