Log in

View Full Version : Need help with ffmpeg dts encoding


mariner
12th January 2016, 14:38
Greetings.

1. The ffmpeg documentation page doesn't seem to list the dts encoder. Appreciate if someone can assist with the syntax and options.

https://ffmpeg.org/ffmpeg-all.html#Audio-Encoders

2. What are the bitrates available for lossy encoding compatible with blu-ray?

3. What bitrate is recommended for close to transparent encoding?

4. What bitrate is considered comparable to 640k ac3 encode, quality wise?

5. Is it the considered opinion of this forum that for similar size encodes, dts offers better quality than ac3?

Many thanks and best regards.

tebasuna51
12th January 2016, 16:59
1)
ffmpeg -encoders
...
A..X.. dca DCA (DTS Coherent Acoustics) (codec dts, Experimental)
...

Sintax:
ffmpeg -i INPUT -strict -2 -acodec dca -ab 1536k OUT.dts

2) 1536 and 768 Kb/s
3) 1536 Kb/s
4) 1536 Kb/s
5) For size/quality AC3 is better.

Read '>' like 'better quality than'
1536 DTS > 640 AC3 > 768 DTS > 448 AC3

BTW the DTS's from ffmpeg maybe aren't full compliant with BD specs, I recommend use:

eac3to INPUT stdout.wav | ffdcaenc (http://forum.doom9.org/showthread.php?p=1688150#post1688150) -i - -o OUT.dts -l -b 1509.75

to obtain the same header than dts obtained with DTS Master Audio commercial encoder.

mariner
13th January 2016, 09:38
Many thanks for the kind reply, tebasuna51.

1)
ffmpeg -encoders
...
A..X.. dca DCA (DTS Coherent Acoustics) (codec dts, Experimental)
...

Sintax:
ffmpeg -i INPUT -strict -2 -acodec dca -ab 1536k OUT.dts

2) 1536 and 768 Kb/s
3) 1536 Kb/s
4) 1536 Kb/s
5) For size/quality AC3 is better.

Read '>' like 'better quality than'
1536 DTS > 640 AC3 > 768 DTS > 448 AC3

A quick test shows 768 dts is about 20% larger than 640k AC3, while the 1536 dts is just as large as the wav. Do these numbers look right?

2.
BTW the DTS's from ffmpeg maybe aren't full compliant with BD specs, I recommend use:

eac3to INPUT stdout.wav | ffdcaenc (http://forum.doom9.org/showthread.php?p=1688150#post1688150) -i - -o OUT.dts -l -b 1509.75

to obtain the same header than dts obtained with DTS Master Audio commercial encoder.

You're right about DTS's from ffmpeg not recognised by tsMuxeR. Process it again by eac3to seems fix the issue. Will this 1536k dts track play in a blu-ray player?

3. How can one use ffmpeg together with ffdcaenc? The following doesn't seem to work.

ffmpeg -i IN.opus -af atrim=.05 -t 500 stdout.wav | ffdcaenc -i - -o OUT.dts -l -b 1509.75

4. Should one use the 1209 version of ffdcaenc?

http://forum.doom9.org/attachment.php?attachmentid=14523&d=1418120288

Many thanks and best regards.

sneaker_ger
13th January 2016, 09:43
A quick test shows 768 dts is about 20% larger than 640k AC3, while the 1536 dts is just as large as the wav. Do these numbers look right?
Of course, it's simple math:
640 kbps * 1,2 = 768 kbps

48 kHz * 16 bit * 2 (channels) = 1536 kbps

nevcairiel
13th January 2016, 10:31
For 2 channel audio, you really don't need to use max bitrate for either AC3 or DTS, the max is designed for 5.1 audio.

tebasuna51
13th January 2016, 14:08
A quick test shows 768 dts is about 20% larger than 640k AC3, while the 1536 dts is just as large as the wav. Do these numbers look right?
The numbers are right.
Use AC3 at 256 Kb/s (or 192 Kb/s) for audio stereo.
I recommend always use AC3 to recode lossy formats (opus, aac, mp3, ...) for compatibility with DVD/BD players. Use DTS, for me, is waste space.

Process it again by eac3to seems fix the issue. Will this 1536k dts track play in a blu-ray player?
Why not?
I don't have a blu-ray player, test it yourself.

3. How can one use ffmpeg together with ffdcaenc? The following doesn't seem to work.
The sintax "stdout.wav" is only for eac3to.
I'm not a ffmpeg expert and I have troubles using "pipe" with it.
Maybe other user can help you.

4. Should one use the 1209 version of ffdcaenc?
The filler56789 builds are for be "*NIX-friendly" and I have troubles using them with eac3to in Windows. Try yourself.

The LoRd_MuldeR build works fine for me with eac3to in Windows.
In theory the parameters and output must be the same.

filler56789
13th January 2016, 16:14
4. Should one use the 1209 version of ffdcaenc?

http://forum.doom9.org/attachment.php?attachmentid=14523&d=1418120288

With sox at least, the stdin support under Windows worked fine.

I didn't test that build against eac3to or ffmpeg, I admit :o

mariner
13th January 2016, 16:56
With sox at least, the stdin support under Windows worked fine.

I didn't test that build against eac3to or ffmpeg, I admit :o

Thanks for the kind reply, filler.

Could not get the following to work. Appreciate any advice.

Many thanks and best regards.

ffmpeg -i IN.opus -t 500 -f wav - | ffdcaenc -i - -o OUT.dts -l -b 1509.75

FFDCAENC --- experimental 'Coherent Acoustics' compressor.
Input: -
Output: fOUT.dts
Bitrate: 1509 kbps

ffmpeg version N-76467-ga8b254e ...
...
...
Input #0, matroska,webm, from 'IN.opus':
Metadata:
encoder : google
Duration: 04:39:13.48, start: 0.007000, bitrate: 138 kb/s
Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Output #0, wav, to 'stdout.wav':
Metadata:
ISFT : Lavf57.14.100
Stream #0:0(eng): Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo
, s16, 1536 kb/s (default)
Metadata:
encoder : Lavc57.14.100 pcm_s16le
Stream mapping:
Stream #0:0 -> #0:0 (opus (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
size= 93714kB time=00:08:20.00 bitrate=1535.4kbits/s
video:0kB audio:93714kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 0.000081%
Could not open or parse "-".
Error: RIFF header not found!
Press any key to continue . . .

filler56789
13th January 2016, 17:52
^ Yes, I could reproduce that error.
Apparently /probably it's ffmpeg's fault...

On the other hand, the latest ffdcaenc worked fine with eac3to,
something like this:

eac3to input48.mp3 stdout.wav|ffdcaenc -i - -o output48.dts -l -b 447

mariner
14th January 2016, 07:40
Thanks for testing, filler.

The syntax used was taken from Selur's post on piping to neroaccenc:
ffmpeg -i "path to audio input" -acodec pcm_s16le -ac 2 -ar 48000 -f wav - | neroAacEnc -if - -br 128000 -ignorelength -of "path to audio output"
http://forum.doom9.org/showthread.php?t=141723


Testing with Aften also works, but with a strange 30ms delay.
ffmpeg.exe -i IN.opus -t 500 -f wav - | aften -b 192 -pad 0 -readtoeof 1 - OUT.ac3

No success however with eac3to. That's leaves two candidates, eac3to and ffdcaenc not working with ffmpeg pipe output.

Anyone here able to get it working?

Many thanks and best regards.

tebasuna51
14th January 2016, 11:48
^ Yes, I could reproduce that error.
Apparently /probably it's ffmpeg's fault...
I agree.
On the other hand, the latest ffdcaenc worked fine with eac3to,
Tested now with W 7 and seems work fine, maybe my troubles was when I still using W XP.

Both ffdcaenc builds (filler56789 and LoRd_MuldeR) produce same length, headers and standard DTS delay (11 ms) but aren't bit-identical.

There are any improvement in encoder part?

In my test encoding the same source and decoded after with libdcadec the outputs differences are below -100 dB (not audible).

No success however with eac3to. That's leaves two candidates, eac3to and ffdcaenc not working with ffmpeg pipe output.
- eac3to don't accept stdin at all, then never can pipe output to it.

eacto only can do stdout in wav or w64 formats.
You can use stdout.wav to pipe to many encoders (Aften, Qaac, fhgaacenc, Lame, ffdcaenc, OggEnc2, NeroAacEnc, opusenc, ...) or other soft like sox.
And use stdout.w64 to pipe to ffmpeg.

- And the error ffmpeg -> ffdcaenc is the same for both ffdcaenc builds (filler56789 and LoRd_MuldeR).

filler56789
15th January 2016, 10:45
........

Both ffdcaenc builds (filler56789 and LoRd_MuldeR) produce same length, headers and standard DTS delay (11 ms) but aren't bit-identical.

There are any improvement in encoder part?

I suppose the difference is caused by the use of different compilers;
Lord_Mulder's build was compiled with Visual Studio,
whereas my build was compiled with GCC.

In my test encoding the same source and decoded after with libdcadec the outputs differences are below -100 dB (not audible).

That's good. FWIW, all the .dts files generated by dcaenc and ffdcaenc have been validated by the program DTS-HD Stream Tools, regardless of bitrate and sampling frequency.

mariner
21st January 2016, 12:26
Greetings tebasuna51 and filler. Many thanks for your help.

Looks like a single step ffmpeg dts encoding solution is not available yet.

richardpl
22nd January 2016, 12:23
The ffmpeg dts encoder uses same core code as ffdcaenc.

mariner
24th January 2016, 14:17
Sadly, none of the dts tracks sound good in a BD player.

richardpl
24th January 2016, 22:14
What ffmpeg version you tried? The git version have fixed 2 serious bugs.

tebasuna51
25th January 2016, 11:51
Using:
ffmpeg -i test.wav -strict -2 -acodec dca -ab 1509000 test1509000.dts
or
ffmpeg -i test.wav -strict -2 -acodec dca -ab 1509750 test1509750.dts


ffmpeg version N-78043-g1d8f9b7 [Latest Zeranoe: git-1d8f9b7 (2016-01-24)]
...
encoder : Lavc57.22.100 dca
...
size= 3752kB time=00:00:20.00 bitrate=1536.8kbits/s speed=12.8x

Problems detected:

FrameLength Expected FrameLength Real
in header bitrate in file bitrate
------------------ ----------- -------- ----------- --------
Master Audio Suite 2013 1509750 2013 1509750
Other standard 2012 1509000 2012 1509000
ffmpeg 2048 (1) 1536000 2049 (2) 1536750

(1) Is a valid value but don't match with standards, also don't obey the requested bitrate.

(2) That is a bug, add a '0' byte to all frames and don't match with FrameLength in header.
Also obtain a real bitrate greater than standard Transmission bitrate 1536000

richardpl
25th January 2016, 17:47
Ok, those 2 bugs should be hopefully fixed now.

SeeMoreDigital
25th January 2016, 17:58
Sadly, none of the dts tracks sound good in a BD player.Did the dts audio sound distorted?

I did some tests using the DCA encoder (dcaenc-2) and noticed that when I played the multi-channel encodes using my Oppo and LG television (and passed the bit-stream to my surround sound amplifier) the audio sounded distorted.

The strange thing is, the same encodes sound fine when played using MPC-BE with LAV!

filler56789
25th January 2016, 20:11
I did some tests using the DCA encoder (dcaenc-2) and noticed that when I played the multi-channel encodes using my Oppo and LG television (and passed the bit-stream to my surround sound amplifier) the audio sounded distorted.

The strange thing is, the same encodes sound fine when played using MPC-BE with LAV!

.......this encoder uses only the most basic compression techniques defined in the DTS specification, and thus cannot win any comparison with commercial DTS encoders.
source: https://github.com/filler56789/ffdcaenc-2/blob/master/README.md

Also, it's not impossible that the hardware-based DTS decoders are "crippled" somehow, much in the same way the official /certified DTS encoders do not go beyond a tiny subset of the full DTS-audio specifications.

SeeMoreDigital
25th January 2016, 20:35
Thanks Filler,

I've also just read this over on github: -
Still, at 754 kbps, the internal psychoacoustical model considers the distortions to be just below the threshold of detection by human ears.
Whilst I'm able to confirm that dts files encoded at 754/768Kbps sound much less distorted when passed as a bit-stream to a hardware dts decoder, the distortion is still very apparent :(


Cheers

mariner
26th January 2016, 08:38
Did the dts audio sound distorted?


In a most disagreeable way.

mariner
26th January 2016, 08:40
What ffmpeg version you tried? The git version have fixed 2 serious bugs.

ffmpeg version N-76467-ga8b254e Copyright (c) 2000-2015 the FFmpeg developers

filler56789
26th January 2016, 09:47
^ Thanks for all the additional info, guys.

Sooner or later, I will have to update ffdcaenc's "README2.TXT" @ GitHub.

SeeMoreDigital
26th January 2016, 16:00
What ffmpeg version you tried? The git version have fixed 2 serious bugs.For information purposes. I've been using the dts encoder in LameXP v4.13 Final-1 Build 1852 [2015-12-12] and the one in UsEac3To v1.1.9.


Cheers