View Full Version : Proper way to FFMPEG DTS-MA 7.1 to AC3 5.1?
tormento
17th November 2017, 11:29
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...
microchip8
17th November 2017, 12:35
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)
tormento
17th November 2017, 14:01
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.
tebasuna51
17th November 2017, 22:53
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:
# 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:
tormento
18th November 2017, 11:23
# 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.
tebasuna51
18th November 2017, 12:39
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.
tebasuna51
18th November 2017, 13:15
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.
tormento
19th November 2017, 08:10
That avs function split the channels in
And how can AviSynth read a DTS?
I really miss all the audio part.
tebasuna51
19th November 2017, 10:46
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 (http://avisynth.nl/index.php/Internal_filters#Audio_processing_filters) and with external Audio filters (http://avisynth.nl/index.php/External_filters#Audio_Filters)
You can see the docs for full explain.
SeeMoreDigital
19th November 2017, 12:12
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
tormento
19th November 2017, 13:05
You can see the docs for full explain.
Thanks.
tebasuna51
19th November 2017, 13:12
There are two generic reasons:
-Compatibility. Not all players support DTS decode.
- Size. 42% size of a core 1509 Kb/s.
tormento
20th November 2017, 10:32
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.
SeeMoreDigital
20th November 2017, 10:44
Okay...
Have you considered using the 5.1 DTS core as a source to generate your 5.1 AC3 encode?
microchip8
21st November 2017, 18:26
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 :devil:
SeeMoreDigital
21st November 2017, 19:50
Compressing compressed audio... compressing compressed audio... and stuff like that :devil: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!
Vicio
13th February 2021, 03:04
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.
https://i.imgur.com/BvaVH0a.png
https://i.imgur.com/UQ8BjYF.png
tebasuna51
13th February 2021, 14:14
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.
tebasuna51
13th February 2021, 15:30
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:
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=0:points=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]"
Remember, the :p is
:p
and 2) to 6) steps the same.
Vicio
14th February 2021, 00:05
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.
https://i.imgur.com/nd2alcn.png
https://i.imgur.com/HMbB3Tm.png
tebasuna51
14th February 2021, 00:07
Of course, but use a AviSynth 32 bits decoder (LWlibav), and the TimeStretch AviSynth 32 bits function, and send the output to ffmpeg EAC3 encoder must be slow than use only the ffmpeg 64 bits.
Using BeHappy AviSynth TimeStretch tempo over a sample I obtain:
size= 78952kB time=00:48:07.38 bitrate= 224.0kbits/s speed= 144x
Using 'atempo' ffmpeg filter I obtain the same output duration but fast:
size= 78953kB time=00:48:07.38 bitrate= 224.0kbits/s speed= 183x
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.