Opened 6 months ago

Last modified 6 months ago

#7011 new defect

Decoding of chained opus streams isn't properly supported

Reported by: neknek446 Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords: opus ogg
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
ffmpeg currently doesn't support chained opus streams (as specified in <https://tools.ietf.org/html/rfc7845.html#section-7.2>).
When decoding opus stream with OpusHead/OpusTags packets not in begining of overall stream, it produces "Error parsing the packet header." error messages and crack noises, and also doesn't update tags.
For opus stream chaining to work, opus decoder (libavformat/oggparseopus.c) should:

  • handle OpusHead packets (including discarding pre-skip ammount of samples). It currently handles this well only in opus_header function.
  • handle OpusTags packets (including updating metadata). It currently handles this well only in opus_header function.
  • handle EOS-marked packets with granule position smaller than last granule position + ammount of samples contained in packet by discarding excess decoded samples. I looked at code and it seems to currently do this already.

How to reproduce:

wget https://jmvalin.ca/misc_stuff/chain_works.opus
ffmpeg -i chain_works.opus chain_works.wav

or

mpv https://jmvalin.ca/misc_stuff/chain_works.opus

or

mplayer https://jmvalin.ca/misc_stuff/chain_works.opus

Also relevant VLC ticket: <https://trac.videolan.org/vlc/ticket/18401>.

Change History (4)

comment:1 Changed 6 months ago by neknek446

I'm not really familiar with codebase so I can't really tell whether oggparseopus.c' opus_packet() should be chagned to handle this or something in oggdec.c should be modified to make it call os->codec->header() (os->header = -1; in ogg_replace_stream() maybe?).

Last edited 6 months ago by neknek446 (previous) (diff)

comment:2 Changed 6 months ago by neknek446

https://github.com/FFmpeg/FFmpeg/commit/c994bb2fb7727f5c20ef71cc6727fb219fd49d60 apparently intentionally disabled codec reinitialisation.

comment:3 Changed 6 months ago by atomnuker

Do any chained opus streams actually exist or is it just that file? Last I looked at it it was just that file.

comment:4 Changed 6 months ago by neknek446

there's ticket (https://github.com/MusicPlayerDaemon/MPD/issues/70) and not yet accepted PR (https://github.com/MusicPlayerDaemon/MPD/pull/205) for mpd.
I'm "cathugger" in there.

Note: See TracTickets for help on using tickets.