Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#7011 closed defect (fixed)

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, epirat07@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 5 years ago.
Log of ffplay attempting to play a chained opus file

Download all attachments as: .zip

Change History (9)

comment:1 by neknek446, 6 years ago

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 years ago by neknek446 (previous) (diff)

comment:2 by neknek446, 6 years ago

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

comment:3 by Rostislav Pehlivanov, 6 years ago

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 by neknek446, 6 years ago

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 by Jookia, 5 years ago

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

by Jookia, 5 years ago

Attachment: opus_chained_errors.log added

Log of ffplay attempting to play a chained opus file

comment:6 by Jookia, 5 years ago

Cc: 166291@gmail.com added

comment:7 by ePirat, 5 years ago

Cc: epirat07@gmail.com added

comment:8 by Lynne, 4 years ago

Resolution: fixed
Status: newclosed
Last edited 4 years ago by Carl Eugen Hoyos (previous) (diff)
Note: See TracTickets for help on using tickets.