Opened 20 months ago

Last modified 12 days 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: 166291@gmail.com 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>.

Attachments (1)

opus_chained_errors.log (104.8 KB) - added by Jookia 12 days ago.
Log of ffplay attempting to play a chained opus file

Download all attachments as: .zip

Change History (7)

comment:1 Changed 20 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 20 months ago by neknek446 (previous) (diff)

comment:2 Changed 20 months ago by neknek446

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

comment:3 Changed 20 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 20 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.

comment:5 Changed 12 days ago by Jookia

This causes issues with web radios that chain opus files.
You can reproduce this issue easily using these commands:

ffmpeg -v 9 -loglevel 99 -f lavfi -i "sine=frequency=1000:duration=5" -c:a libopus a.ogg 
ffmpeg -v 9 -loglevel 99 -f lavfi -i "sine=frequency=2000:duration=5" -c:a libopus b.ogg 
cat a.ogg b.ogg > c.ogg
ffplay -v 9 -loglevel 99 -nodisp c.ogg 2>&1 | tee opus_chained_errors.log

Changed 12 days ago by Jookia

Log of ffplay attempting to play a chained opus file

comment:6 Changed 12 days ago by Jookia

  • Cc 166291@gmail.com added
Note: See TracTickets for help on using tickets.