Convert DTS to Opus

Questions involving a Windows version of FFmpeg.
Post Reply
MeisterKnobi
Posts: 4
Joined: Thu May 02, 2019 3:47 pm

Convert DTS to Opus

Post by MeisterKnobi » Thu May 02, 2019 4:01 pm

Hello,

im struggle to find the right arguments or more i dont know what im realy doing...
i ve been using

Code: Select all

ffmpeg -i "Input.mka" -c:a libopus -vbr on -ac 6 "Output.mka"
and

Code: Select all

ffmpeg -i "Input.mka" -c:a libopus -vbr 2 -ac 6 "Output.mka"
But booth times it sets an Deafault bitrate at 320k.

Code: Select all

[libopus @ 0000020a75f224c0] No bit rate set. Defaulting to 320000 bps.
Plese correct me if im wrong but is the point of vbr not to use an fixed bitrate?

Can some tell me if im doing it right or what im doing wrong? Some simple example lines would been helpfull to.

Greedings Meister_Knobi

at2010
Posts: 10
Joined: Sun Apr 28, 2019 10:31 pm

Re: Convert DTS to Opus

Post by at2010 » Tue May 07, 2019 9:47 pm

Hi.

Nothing is really wrong with your transcoding. A quick look at the help option of ffmpeg:

Code: Select all

ffmpeg -h encoder=libopus
yields:

Code: Select all

Encoder libopus [libopus Opus]:
    General capabilities: delay small
    Threading capabilities: none
    Supported sample rates: 48000 24000 16000 12000 8000
    Supported sample formats: s16 flt
libopus AVOptions:
  -application       <int>        E...A.... Intended application type (from 2048 to 2051) (default audio)
     voip                         E...A.... Favor improved speech intelligibility
     audio                        E...A.... Favor faithfulness to the input
     lowdelay                     E...A.... Restrict to only the lowest delay modes
  -frame_duration    <float>      E...A.... Duration of a frame in milliseconds (from 2.5 to 120) (default 20)
  -packet_loss       <int>        E...A.... Expected packet loss percentage (from 0 to 100) (default 0)
  -vbr               <int>        E...A.... Variable bit rate mode (from 0 to 2) (default on)
     off                          E...A.... Use constant bit rate
     on                           E...A.... Use variable bit rate
     constrained                  E...A.... Use constrained VBR
  -mapping_family    <int>        E...A.... Channel Mapping Family (from -1 to 255) (default -1)
  -apply_phase_inv   <boolean>    E...A.... Apply intensity stereo phase inversion (default true)
  
so your choice of -vbr 2 is suspect. 0=off, 1=on (default) and 2 = constrained vbr (closer to cbr). If you are looking for best variable encoding then either omit -vbr or specify -vbr on.

The default value of 320000 (= 320k bp/s) (for all 6 channels) is a relative indicator of quality with the value shown as more of an average bit rate. I find the default value of 320k for 6 channels to be of modest quality. A 6ch value of 448k very good (dvd) quality. 640k is closer to bluray. At these higher bit rates, Opus and AAC are about the same but with Opus having lower latency and less patent encumbrance:
https://www.opus-codec.org/comparison/
FFmpeg docs show a "compression_level" parameter with a default value of 10. I experimented with this thinking it would change the defaulted average bit rate. It didn't. So your best bet is to alter the bitrate value.
Also it seems to be best to always specify audio channels -ac , since it defaults to -1 and may give you an error.

You don't really state what you are trying to achieve in terms of quality, other than a 6 channel transcoding.
A few examples:
Accept the default 320k bp/s for 6 ch encoding:

Code: Select all

ffmpeg -i "Input.mkv" -map -0:a -c:a libopus  -ac 6 "Output.mka"
Set a higher 6 ch quality at 448k average:

Code: Select all

ffmpeg -i "Input.mkv" -map -0:a -c:a libopus  -b:a 448k -ac 6 "Output.mka"
Downmix to stereo (the default is 96k for 2 ch):

Code: Select all

ffmpeg -i "Input.mkv" -map -0:a -c:a libopus  -b:a 192k -ac 2 "Output.mka"
Set a constant 6 ch bit rate:

Code: Select all

ffmpeg -i "Input.mkv" -map -0:a -c:a libopus  -vbr off b:a 384k -ac 6 "Output.mka"
Hope this helps.

MeisterKnobi
Posts: 4
Joined: Thu May 02, 2019 3:47 pm

Re: Convert DTS to Opus

Post by MeisterKnobi » Sun May 12, 2019 8:38 pm

Thanks for you explanation.
Also it seems to be best to always specify audio channels -ac , since it defaults to -1 and may give you an error.
Yeah, i expirienced that it woult keep all 6 channels, but it lost the mapping of the channels so at 6ch the resault was pretty mutch trash. 2ch files were fine.
The default value of 320000 (= 320k bp/s) (for all 6 channels) is a relative indicator of quality with the value shown as more of an average bit rate. I find the default value of 320k for 6 channels to be of modest quality. A 6ch value of 448k very good (dvd) quality. 640k is closer to bluray. At these higher bit rates, Opus and AAC are about the same but with Opus having lower latency and less patent encumbrance:
https://www.opus-codec.org/comparison/
320k compared to DTS is allready so small that i think just stick with 640k for 6ch, since i have no target i want to reach, just save some space. For 2ch you wolud also recommend double the BR up tu 192k?

Anyway. Thanks for your help, i have not the right equipment nor the trained auditory to hear the diffrence.

freultwah
Posts: 1
Joined: Sat Nov 09, 2019 10:51 pm

Re: Convert DTS to Opus

Post by freultwah » Sat Nov 09, 2019 11:06 pm

Opus at 256 kbps for 5.1 and even 7.1 is quite sufficient, transparent even. Source: https://wiki.xiph.org/Opus_Recommended_Settings. Opus uses something they call surround-sound bitrate allocation, i.e. bitrate is used where it's needed at that point, it's not wasted on the odd bang and mostly birds chirping in the rear channels, for example.

My [slightly redacted] command line that does not mess up channel order and all works well and sounds good (given that there's just one video and just one audio track):

Code: Select all

ffmpeg -i source.mkv \
  -c:v libx265 -c:a libopus \
  -b:a:0 256k \
  -map 0:v:0 -map 0:a:0 \
  -filter:a:0 "aformat=channel_layouts=5.1|7.1" \
  -crf 23 \
  -preset fast \
  -x265-params colorprim=bt709:transfer=bt709:colormatrix=bt709:no-strong-intra-smoothing=1:me=star:wpp=1:early-skip=1:merange=20:aq-mode=2:no-sao=1:qcomp=0.8:no-rect=1:pools=4 \
  -metadata:s:v:0 language=und -metadata:s:v:0 title="Video Track" \
  -metadata:s:a:0 language=eng -metadata:s:a:0 title="Surround Track" \
  output.mkv
I think your channel order issue is related to the lack of the

Code: Select all

-filter:a:0 "aformat=channel_layouts=5.1|7.1"
bit. It detects the channel count of the original and, considering the standard order of the source and the target formats, sets the mapping accordingly. That's the bit to take from here. No need to delve much into my libx265 encoder settings, even though you can use them, because they seem to bypass the standard issue of x265 oversmoothing everything up to 1080p.

Post Reply
'