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 > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th November 2017, 11:29   #1  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,563
Proper way to FFMPEG DTS-MA 7.1 to AC3 5.1?

I have googled lot of sites but didn't find answer.

Is possible to use ffmpeg to convert a DTS-MA 7.1 file to AC3 5.1 (640kbps) with proper channel mapping and mixdown?

Eac3to gives me error and ffmpeg seems my only viable way...
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 17th November 2017, 12:35   #2  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
yes, just use -ac 6 in ffmpeg and it does its auto-magic. I use it all the time and the result is always correct (tested on my surround system)
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 17th November 2017, 14:01   #3  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,563
Quote:
Originally Posted by froggy1 View Post
yes, just use -ac 6 in ffmpeg and it does its auto-magic. I use it all the time and the result is always correct (tested on my surround system)
Great, thanks. I tried also to find a gui that process audio files only but nothing found. What a pity.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 17th November 2017, 22:53   #4  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,914
ffmpeg and eac3to (-down6) can do the job.

But when downmix the overall volume can be reduced, to avoid clip when SL,BL and SR,BR are mixed.
I can recommend a special AviSynth downmix to preserve the full volume in FL,FR,FC,LFE channels.
In short something like:

Code:
# Downmix 7.1 to 5.1
function 71to51(clip a) {
  flr = Getchannel(a, 1, 2, 3, 4)
  blr = Getchannel(a, 5, 6)
  slr = Getchannel(a, 7, 8)
  sur = MixAudio(blr, slr, 1.0, 1.0).SoftClipperFromAudX(0.0)
return mergechannels(flr,sur)
}
That it is available in MeGUI or BeHappy.
For instance in MeGUI with a DTS-HD source:
Attached Images
 
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 18th November 2017, 11:23   #5  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,563
Quote:
Originally Posted by tebasuna51 View Post
Code:
# Downmix 7.1 to 5.1
function 71to51(clip a) {
  flr = Getchannel(a, 1, 2, 3, 4)
  blr = Getchannel(a, 5, 6)
  slr = Getchannel(a, 7, 8)
  sur = MixAudio(blr, slr, 1.0, 1.0).SoftClipperFromAudX(0.0)
return mergechannels(flr,sur)
}
Tell me more about this, please.

I never used AVS to encode/decode audio.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 18th November 2017, 12:39   #6  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,914
That avs function split the channels in:

flr = Getchannel(a, 1, 2, 3, 4) # channels FL, FR, FC, LFE
blr = Getchannel(a, 5, 6) # channels BL, BR
slr = Getchannel(a, 7, 8) # channels SL, SR

Now mix channels BL with SL, BR with SR

sur = MixAudio(blr, slr, 1.0, 1.0)

The mix is at full volume (1.0) and can produce clip if sum of volumes is greater than 1.0 (float samples are used at this point)
And apply a plugin (Audiolimiter.dll) to reduce volume only if clip is detected, to limit max volume at 1.0:

sur = sur.SoftClipperFromAudX(0.0)

and finally return the 6 channels without changes in 'flr'

return mergechannels(flr,sur)

Then most the time the volume in 'sur' is the same than in the 4 surround channels, and the global balance between front and surround is preserved.
Only in clip points the balance is lost and 'sur' (two speakers) can't produce the same volume than BL,BR,SL,SR (four speakers).

The standard way to mix 7.1 -> 5.1 is lower the volume of ALL channels to prevent clips and you have correct balance in all the movie but at half volume.
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 18th November 2017 at 13:40. Reason: add info
tebasuna51 is offline   Reply With Quote
Old 18th November 2017, 13:15   #7  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,914
OTHER QUESTIONS:

- That MeGUI method work also for 6.1 sources (other fuction 61to51 is selected) and DTS-HR 96 KHz (Change to 48000, than do nothing if it is already 48000).

- The LWLibavAudioSource can decode many audio sources (DTS-HD, TrueHD, FLAC, AAC, ...), and also the first audio track of containers like m2ts or mkv.

- You can include other parameters to ffmpeg encoder in Extra Tab, for instance I recommend:

-center_mixlev 0.707

to override the ffmpeg default 0.594604, to low for me, used if decoder need downmix to stereo that 5.1.
Attached Images
 
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 18th November 2017 at 14:16.
tebasuna51 is offline   Reply With Quote
Old 19th November 2017, 08:10   #8  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,563
Quote:
Originally Posted by tebasuna51 View Post
That avs function split the channels in
And how can AviSynth read a DTS?

I really miss all the audio part.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 19th November 2017, 10:46   #9  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,914
The same than video, with a proper spliter/decoder.
The plugin LSMASHSource.dll (also ffms2.dll) have functions:

LWLibavVideoSource("inputfile",...)
LWLibavAudioSource("inputfile",...)
...

It convert many sources to uncompressed PCM samples than can be managed inside AviSynth with internal Audio processing filters and with external Audio filters

You can see the docs for full explain.
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 19th November 2017 at 10:49. Reason: typo
tebasuna51 is offline   Reply With Quote
Old 19th November 2017, 12:12   #10  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
Quote:
Originally Posted by tormento View Post
Is possible to use ffmpeg to convert a DTS-MA 7.1 file to AC3 5.1 (640kbps) with proper channel mapping and mixdown?
Is there any particular reason why you require Dolby Digital (AC3) audio stream and can't use the DTS core?


Cheers
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 19th November 2017, 13:05   #11  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,563
Quote:
Originally Posted by tebasuna51 View Post
You can see the docs for full explain.
Thanks.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 19th November 2017, 13:12   #12  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,914
There are two generic reasons:

-Compatibility. Not all players support DTS decode.

- Size. 42% size of a core 1509 Kb/s.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 20th November 2017, 10:32   #13  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,563
Quote:
Originally Posted by tebasuna51 View Post
There are two generic reasons:
-Compatibility. Not all players support DTS decode.
- Size. 42% size of a core 1509 Kb/s.
Both are valid to me.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 20th November 2017, 10:44   #14  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
Okay...

Have you considered using the 5.1 DTS core as a source to generate your 5.1 AC3 encode?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 21st November 2017, 18:26   #15  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,844
Quote:
Originally Posted by SeeMoreDigital View Post
Okay...

Have you considered using the 5.1 DTS core as a source to generate your 5.1 AC3 encode?
Compressing compressed audio... compressing compressed audio... and stuff like that
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 21st November 2017, 19:50   #16  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
Quote:
Originally Posted by froggy1 View Post
Compressing compressed audio... compressing compressed audio... and stuff like that
Yes we all know this, but....

Unless tormento has a well spec'd surround sound set-up (which he can't have or he'd be keeping the original DTS-MA stream or using the DTS core), he's unlikely to hear that much of a difference!
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 13th February 2021, 03:04   #17  |  Link
Vicio
Registered User
 
Join Date: May 2017
Posts: 18
Quote:
Originally Posted by tebasuna51 View Post
OTHER QUESTIONS:

- That MeGUI method work also for 6.1 sources (other fuction 61to51 is selected) and DTS-HR 96 KHz (Change to 48000, than do nothing if it is already 48000).

- The LWLibavAudioSource can decode many audio sources (DTS-HD, TrueHD, FLAC, AAC, ...), and also the first audio track of containers like m2ts or mkv.

- You can include other parameters to ffmpeg encoder in Extra Tab, for instance I recommend:

-center_mixlev 0.707

to override the ffmpeg default 0.594604, to low for me, used if decoder need downmix to stereo that 5.1.
Hello, when should the command line (-center_mixlev 0.707) be used?
Only for 6.1 / 5.1 to 2.0 audio conversions or should it also be used for 2.0 to 2.0 audio conversions?
I ask this because I went to change the speed of a DDP audio (EAC3) with eac3to.exe the conversion was carried out, but however the command was not applied.




Last edited by Vicio; 13th February 2021 at 03:07.
Vicio is offline   Reply With Quote
Old 13th February 2021, 14:14   #18  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,914
Quote:
Originally Posted by Vicio View Post
Hello, when should the command line (-center_mixlev 0.707) be used?
Only for 6.1 / 5.1 to 2.0 audio conversions or should it also be used for 2.0 to 2.0 audio conversions?
1) The center_mixlevel is not a field in eac3 bsi header then ffmpeg say than can't be used. Correct.
My template is for ac3 encode, you can change it for eac3 but you can delete also that parameter.

2) In ac3 2.0 bsi header also don't exist the field center_mixlevel, you can also delete it. My template is for multichannel because for 2.0 always recommend recode to AAC.

BTW ffmpeg yelow warnings aren't a problem, are only info.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 13th February 2021, 15:30   #19  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,914
To change duration of audio tracks you can use UsEac3to and ffmpeg without eac3to.

Sometimes eac3to can't decode the source track or you want preserve the pitch of the track (eac3to change the pitch when you change the audio duration).

See the image. You want change the EAC3 english track.

1) Use the 'More parameters' -> F-FFMPEG -> Add or write directly in 'COMMAND LINE PARAMETERS' the ffmpeg audio filter:
-af "atempo=1.001"

with:
Code:
 fps's video     TimeStretch ffmpeg
---------------- -------------------
23.976 -> 25.000   1.042708  speedup
23.976 -> 24.000   1.001
24.000 -> 25.000   1.041667
24.000 -> 23.976   0.999001
25.000 -> 24.000   0.96
25.000 -> 23.976   0.959041  slowdown
2) Open the 'A/V Recode' window

3) Select the track to modify. Remember ffmpeg start by track '0' then the eac3to track 3: is the map=0:2 for ffmpeg

4) 'Add to DEC' the ffmpeg filter included in the 'COMMAND LINE PARAMETERS'

5) Select the output format and bitrate/quality: AC3, EAC3, AAC (recommended for 2.0), ...

6) 'Run' or 'EnQueue'

- Like this thread is for Downmix 7.1 to 5.1 the method can be used also for that using the ffmpeg filter in 1):

-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0oints=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]"

Remember, the is
Code:
:p
and 2) to 6) steps the same.
Attached Images
 
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 13th February 2021 at 15:41.
tebasuna51 is offline   Reply With Quote
Old 14th February 2021, 00:05   #20  |  Link
Vicio
Registered User
 
Join Date: May 2017
Posts: 18
Quote:
Originally Posted by tebasuna51 View Post
To change duration of audio tracks you can use UsEac3to and ffmpeg without eac3to.
Thank you very much, the tips are of great help.
In fact, when it comes to handling EAC3 audios I really prefer BeHappy, I asked the question because I was surprised to see that in UsEac3to it was possible to change the speed of this audio format as well.

When I saw that he did not apply the command “-center_mixlev 0.707” to the EAC3 audio, I was in doubt if the command was really necessary for 2.0 audios
But now with your explanation I know that it is intended for multichannel only.

Greetings from Brazil.



Vicio 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 05:39.


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