Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#5509 closed defect (fixed)

ffmpeg loses Opus Codec delay on remuxing

Reported by: kagami Owned by:
Priority: important Component: avformat
Version: git-master Keywords: opus codecpar regression
Cc: Michael Niedermayer Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

How to reproduce:

$ ./ffmpeg -version
ffmpeg version N-79754-g66eb5b8 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.3 (Gentoo 4.9.3 p1.4, pie-0.6.4)
configuration: --disable-all --disable-stripping --disable-doc --enable-gpl --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avutil --enable-swresample --enable-swscale --enable-avfilter --disable-bzlib --disable-xlib --disable-zlib --disable-libxcb --disable-sdl --disable-iconv --enable-decoder=opus --enable-parser=opus --enable-demuxer=matroska --enable-muxer=webm --enable-protocol=file
libavutil      55. 23.100 / 55. 23.100
libavcodec     57. 38.100 / 57. 38.100
libavformat    57. 36.100 / 57. 36.100
libavfilter     6. 44.100 /  6. 44.100
libswscale      4.  1.100 /  4.  1.100
libswresample   2.  0.101 /  2.  0.101

$ ./ffmpeg -hide_banner -f lavfi -i anullsrc -t 1 -c libopus 1.webm
Input #0, lavfi, from 'anullsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s
[libopus @ 0x75d120] No bit rate set. Defaulting to 96000 bps.
[webm @ 0x75b900] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, webm, to '1.webm':
  Metadata:
    encoder         : Lavf57.36.100
    Stream #0:0: Audio: opus, 48000 Hz, stereo, s16, 96 kb/s
    Metadata:
      encoder         : Lavc57.38.100 libopus
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_u8 (native) -> opus (libopus))
Press [q] to stop, [?] for help
size=       1kB time=00:00:01.01 bitrate=   7.6kbits/s speed= 152x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 526.797363%

$ mkvinfo 1.webm | grep delay                                    
|  + Codec delay: 6.500ms (6500000ns)

$ ./ffmpeg -hide_banner -i 1.webm -c copy 2.webm
Input #0, matroska,webm, from '1.webm':
  Metadata:
    encoder         : Lavf57.36.100
  Duration: 00:00:01.01, start: -0.007000, bitrate: 7 kb/s
    Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp (default)
[webm @ 0x23e12c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, webm, to '2.webm':
  Metadata:
    encoder         : Lavf57.36.100
    Stream #0:0: Audio: opus, 48000 Hz, stereo (default)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=       1kB time=00:00:01.00 bitrate=   7.6kbits/s speed=2.81e+03x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 441.477264%

$ mkvinfo 2.webm | grep delay
<nothing>

I did bisect and found that this is introduced by 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (Apr 10). Note that lack of Codec delay parameter makes such files unplayable in latest Firefox.

Change History (7)

comment:1 by Carl Eugen Hoyos, 8 years ago

Keywords: opus codecpar regression added
Priority: normalimportant
Status: newopen

For future tickets: Please do not use -hide_banner, it generally makes tickets invalid.

comment:2 by kagami, 8 years ago

Firefox issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1276238
Latest response:

Timothy B. Terriberry (:derf) 2016-05-31 10:29:11 PDT

Echoing what I said in #opus on Friday:

<+derf> jya: I'd say if the file has a non-zero preskip value and no CodecDelay,
then we're well within our rights to reject it.
<+derf> Any codec-agnostic demuxer (to the extent such a thing is even possible)
is going to do the wrong thing with that file.

comment:3 by Michael Niedermayer, 8 years ago

Resolution: fixed
Status: openclosed

Should be fixed by d953b2857b5b51ba363163139bf661216e0ee57c
please reopen ticket if not

comment:4 by kagami, 8 years ago

Resolution: fixed
Status: closedreopened

Codec delay field persist on remuxing now but it's not equal to the original value:

$ mkvinfo 1.webm | grep delay                                    
|  + Codec delay: 6.500ms (6500000ns)
$ ffmpeg -i 1.webm -c copy 2.webm
$ mkvinfo 2.webm | grep delay
|  + Codec delay: 7.000ms (7000000ns)

Thus Firefox still doesn't want to play it because codec delay doesn't match preskip value (at stated in bugzilla ticket).

comment:5 by Michael Niedermayer, 8 years ago

Resolution: fixed
Status: reopenedclosed

Should be fixed by b5bc436ebc57ec60d87f86008a1888fbfb4099bc
please reopen ticket if not

comment:6 by Michael Niedermayer, 8 years ago

Cc: Michael Niedermayer added

comment:7 by kagami, 8 years ago

Now it works. Thank you!

Note: See TracTickets for help on using tickets.