pdeljanov / Symphonia

Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Mozilla Public License 2.0
2.42k stars 144 forks source link

mp3 Seeking has warnings in logs #274

Open hasezoey opened 7 months ago

hasezoey commented 7 months ago

I have noticed that when playing mp3's and then seek, the following warnings / messages come up in the logs, while also in the audio output being noticeable "noise":

[WARN  symphonia_bundle_mp3::demuxer]: invalid mpeg audio header
[WARN  symphonia_bundle_mp3::demuxer]: skipping junk at 844617 bytes
[WARN  symphonia_bundle_mp3::layer3]: mpa: invalid main_data_begin, underflow by 28 bytes
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[WARN  symphonia_bundle_mp3::demuxer]: skipping junk at 926290 bytes
[WARN  symphonia_bundle_mp3::layer3]: mpa: invalid main_data_begin, underflow by 25 bytes
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[WARN  symphonia_bundle_mp3::layer3]: mpa: invalid main_data_begin, underflow by 1 bytes
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[WARN  symphonia_bundle_mp3::demuxer]: skipping junk at 926290 bytes
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: big_values overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[WARN  symphonia_bundle_mp3::demuxer]: invalid mpeg audio header
[WARN  symphonia_bundle_mp3::demuxer]: skipping junk at 844617 bytes
[WARN  symphonia_bundle_mp3::layer3]: mpa: invalid main_data_begin, underflow by 72 bytes
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: big_values overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: big_values overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[WARN  symphonia_bundle_mp3::layer3]: mpa: invalid main_data_begin, underflow by 12 bytes
[WARN  symphonia_bundle_mp3::layer3]: mpa: invalid main_data_begin, underflow by 13 bytes
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream
[INFO  symphonia_bundle_mp3::layer3::requantize]: count1 overrun, malformed bitstream

This seems to only happen on mp3's, not on mka(vorbis) or m4a(aac), with the same (transpiled) track; this also happens on any other mp3 i try.

This happens in both SeekMode::Coarse and SeekMode::Accurate.

I could not reproduce this on symphonia-play as that does not have live seek (only initial seek).

symphonia 0.5.4 rustc 1.77.1 linux (playback via cpal alsa into pipewire)

For context, some code: how the seek is done and the decode loop

Note: even when adding a required_ts check like in symphonia-play, it does not change the warnings or outputted "noise" Note: i used "noise" as i dont quite know how else to describe it other than a mix of "popping" and "squeaking"

sample with 5 seeks done at somewhat regular intervals sample.tar.gz (length: 2 seconds)

hasezoey commented 7 months ago

Update: i have now read over the documentation again for seeking, it says that the decoder should be reset after seeking, which actually helped for mp3, though it seems to not be required for other decoders.

After a seek, all Decoders consuming packets from this reader should be reset.

Another Update: resetting the decoder works for working around the issue of the audible noise (as provided in the sample) in mp3, but resetting the decoder after a seek in mka(vorbis) actually always plays from the beginning (note that resetting the decoder does not resolve the warning messages)