Opened 10 years ago

Last modified 10 years ago

#3803 reopened enhancement

Calculate actual bitrate of first frame when reading cbr dts

Reported by: ptalarbvorm Owned by:
Priority: wish Component: avcodec
Version: git-master Keywords: dca
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:

When adding a WAV header to a dts stream, FFmpeg writes the value read from the dts "target bitrate" field, which almost-always is not the actual bitrate of the stream. DTS in a WAV container is accepted by VirtualDub's AVI muxer, and so far I have to hex-edit the WAVved DTS files created through FFmpeg.

How to reproduce:

1) Create a dts file from an Audio CD track;

dcaenc -i CD_Track_01.wav -o track_01.dts -b 441

2) Mux with FFmpeg;

ffmpeg -i track_01.dts -acodec copy track_01.WAV

The RIFF header will report "448kbps", instead of *441kbps*, which is the correct value.

Change History (5)

comment:1 by Carl Eugen Hoyos, 10 years ago

Please explain why the incorrect bitrate is a problem.
To make this a valid ticket, please provide your FFmpeg command line that does not produce the expected output file together with the complete, uncut console output and please provide a short dts input sample.

Doesn't the FFmpeg avi muxer support dts?

comment:2 by ptalarbvorm, 10 years ago

1) Okay, I've just uploaded two files to the FTP server,
"cdtrack-264.6kbps-dts.txt" and "cdtrack-264.6kbps-dts.wav"

2)

=>ffmpeg -i cdtrack264kbps.dts
ffmpeg version N-63746-gfbaf73a Copyright (c) 2000-2014 the FFmpeg developers
built on Jun 3 2014 22:02:00 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib

libavutil 52. 89.100 / 52. 89.100
libavcodec 55. 66.100 / 55. 66.100
libavformat 55. 42.100 / 55. 42.100
libavdevice 55. 13.101 / 55. 13.101
libavfilter 4. 5.100 / 4. 5.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100

[dts @ 02ec25a0] Estimating duration from bitrate, this may be inaccurate
Input #0, dts, from 'cdtrack264kbps.dts':
Duration: 00:01:29.24, start: 0.000000, bitrate: 320 kb/s
Stream #0:0: Audio: dts (DTS), 44100 Hz, stereo, fltp, 320 kb/s

===========================================================================

=>ffmpeg -i cdtrack264kbps.dts -acodec copy cdtrack-264.6kbps-dts.wav
ffmpeg version N-63746-gfbaf73a Copyright (c) 2000-2014 the FFmpeg developers
built on Jun 3 2014 22:02:00 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib

libavutil 52. 89.100 / 52. 89.100
libavcodec 55. 66.100 / 55. 66.100
libavformat 55. 42.100 / 55. 42.100
libavdevice 55. 13.101 / 55. 13.101
libavfilter 4. 5.100 / 4. 5.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100

[dts @ 02ddacc0] Estimating duration from bitrate, this may be inaccurate
Input #0, dts, from 'cdtrack264kbps.dts':
Duration: 00:01:29.24, start: 0.000000, bitrate: 320 kb/s
Stream #0:0: Audio: dts (DTS), 44100 Hz, stereo, fltp, 320 kb/s
Output #0, wav, to 'cdtrack-264.6kbps-dts.wav':
Metadata:
ISFT : Lavf55.42.100
Stream #0:0: Audio: dts ([1] [0][0] / 0x2001), 44100 Hz, stereo, 320 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, ? for help
size= 3486kB time=00:01:47.82 bitrate= 264.9kbits/s
video:0kB audio:3486kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.002577%

3) «Please explain why the incorrect bitrate is a problem.»

Because it's the WRONG way to do the thing.

comment:3 by Carl Eugen Hoyos, 10 years ago

Keywords: dca added
Priority: normalminor
Resolution: wontfix
Status: newclosed
Version: unspecifiedgit-master

I suspect that FFmpeg cannot know the exact bitrate of a dts file, so I don't think this can be fixed.
Please reopen if you have any indication that the actual bitrate is stored in your input file.

comment:4 by ptalarbvorm, 10 years ago

FWIW --- MediaInfo knows how to calculate the exact bitrate of a "normal" (pure CBR) DCA stream. LeeAudBi.exe (by tebasuna51) and eac3to.exe (by madshi) are able to do that as well.

comment:5 by Carl Eugen Hoyos, 10 years ago

Component: undeterminedavcodec
Priority: minorwish
Reproduced by developer: set
Resolution: wontfix
Status: closedreopened
Summary: Incorrect bitrate in RIFF header when wrapping dts in WAVCalculate actual bitrate of first frame when reading cbr dts
Type: defectenhancement
Note: See TracTickets for help on using tickets.