Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid files(checked by FFprobe) aren't properly parsed in Symphonia #124

Open
qarmin opened this issue May 9, 2022 · 8 comments
Open

Valid files(checked by FFprobe) aren't properly parsed in Symphonia #124

qarmin opened this issue May 9, 2022 · 8 comments
Milestone

Comments

@torokati44
Copy link

I don't know if their license allows looking at it, or taking inspiration from it, but FFmpeg does a more elaborate check during MP3 frame header synchronization; looking ahead in the buffer and scoring any candidates, then picking the one that looks best: https://github.com/FFmpeg/FFmpeg/blob/38238b604fb59ebaafe93dcf72e544cb33c4ac70/libavformat/mp3dec.c#L499-L547=

@qarmin qarmin changed the title Valid files(checked by FFprobe) doesn't properly parse in Symphonia Valid files(checked by FFprobe) aren't properly parsed in Symphonia May 10, 2022
@pdeljanov
Copy link
Owner

I didn't try them all, but for all the MP3 files I tried, the issue seems to be within the ID3v2 parser being too strict. It's encountering a tag with size == 0 which is not allowed by the spec. and returning an error. That error then gets propagated and causes the entire stream to be rejected. With a bit of work, the parser can be made more lenient to allow this case.

The WAV files seems to have a similar issue, but I'd need to look more deeply.

As for the AC3 file, Symphonia does not support AC3. :)


I don't think gaining mild inspiration is problematic, but FFMpeg is LGPL licensed and Symphonia is MPL licensed so copying isn't allowed since our license has fewer restrictions. Either way, for these issues it doesn't seem to be the packet parsing that's the issue.

@torokati44
Copy link

Either way, for these issues it doesn't seem to be the packet parsing that's the issue.

Okay, that's good! I just thought that it is a regression in 8f4aaed as it was explicitly mentioned. Sorry for the confusion.

pdeljanov added a commit that referenced this issue May 30, 2022
pdeljanov added a commit that referenced this issue May 30, 2022
@pdeljanov
Copy link
Owner

The broken MP3s should be fixed with the last two commits.

@pdeljanov
Copy link
Owner

Regarding the wave files:

  • sample.wav and idw_testsound.wav are ADPCM Wave files and are unsupported currently. ADPCM support #41 tracks ADPCM support.
  • jetpack1.wav is technically an invalid encoding, but Symphonia should probably handle it.

@sscobici
Copy link

sscobici commented Dec 25, 2024

See below analysis of the files in 0.6 branch:
Note If "ffmpeg - no errors" is not stated, then there are errors in ffmpeg.
Probably, a separate issue can be opened for point 1. to support mixed files (mono and stereo), as the standard doesn't restrict that. The rest seem to be broken files. All of them are playable except for double speed playback for mono files on Windows, which is expected.d, see #281 (comment)

1. mp3 with different types of frames: starts with mono, continue with stereo - there is a TODO in the code to implement support for this

0086 festung_breslau.mp3
	constain bad MP3 frame at offset: 0x0015202A  (mpa: invalid audio buffer signal spec for packet)
	starts with mono, 64kbs and then switch to stereo, 320kbs
	mono
	
Robin Cook - Pandemia (54).mp3
	constain bad MP3 frame at offset: 0x00099839 ( mpa: invalid audio buffer signal spec for packet )
	starts with mono, 96kbs and then switch to stereo, 320kbs
	plays ok

2. invalid main_data offset, ffmpeg produces no errors (probably weak ffmpeg validation)

3_LIST_SW_JANA.mp3
        fails on first packet at offset: 827842 ( mpa: invalid main_data offset) 
	plays ok
	ffmpeg - no errors

01 Can't Believe My Eyes.mp3
	constain bad MP3 frame at offset: 0x00B4609D, almost at the end of file ( mpa: invalid main_data offset )
	plays ok,
	ffmpeg - no errors

5 - The Music Of Stasis - Stars And The Moons - Meesah Kuteyi feat Mark Morgan.mp3
	constain bad MP3 frame at offset: 0x0039F67E, almost at the end of file ( mpa: invalid main_data offset )
	plays ok,
	ffmpeg - no errors

Grendel.mp3
	constain bad MP3 frame at offset: 0x00A9DFA2 almost at the end of file ( mpa: invalid main_data offset )
	plays ok,
	ffmpeg - no errors

The Way It Was.mp3
	constain bad MP3 frame at offset: 0x003BAB19 almost at the end of file ( mpa: invalid main_data offset )
	plays ok,
	ffmpeg - no errors

3. ID3v1 tag is present in the middle of the file, this is not allowed.

35 - Moj przyjaciel Kaligula.mp3
	contains ID3v1 in the middle of MP3 frames at offset: 0x00048557, Usual frame size is 209. next mp3 frame starts from tag offset + usual frame size
	ID3v1 is not expected in the middle of MP3 frames. 
	mono

55-Steve Jobs Biografia - Rozdzial 26 cz1.mp3
	contains ID3v1 in the middle of MP3 frames at offset: 0x0005A84F, Usual frame size is 208. next mp3 frame starts from tag offset + usual frame size
	ID3v1 is not expected in the middle of MP3 frames. 
	mono

59-Steve Jobs Biografia - Rozdzial 28 cz1.mp3
	contains ID3v1 in the middle of MP3 frames at offset: 0x0003A11F, Usual frame size is 208. next mp3 frame starts from tag offset + usual frame size
	ID3v1 is not expected in the middle of MP3 frames. 
	mono

71-Steve Jobs Biografia - Rozdzial 32 cz2.mp3
	contains ID3v1 in the middle of MP3 frames at offset: 0x00035C0F, Usual frame size is 208. next mp3 frame starts from tag offset + usual frame size
	ID3v1 is not expected in the middle of MP3 frames. 
	mono

19-Dzienniki kolymskie.mp3
	contains ID3v1 in the middle of MP3 frames at offset: 0x00042FD0, Usual frame size is 417. next mp3 frame starts from tag offset + usual frame size
	ID3v1 is not expected in the middle of MP3 frames. 
	mono
	
20-Dzienniki kolymskie.mp3
	contains ID3v1 in the middle of MP3 frames at offset: 0x0008F09B, Usual frame size is 417. next mp3 frame starts from tag offset + usual frame size
	ID3v1 is not expected in the middle of MP3 frames. 
	mono

13 Ekspozycja.mp3
	contains ID3v1 in the middle of MP3 frames at offset: 0x000AB7F2, Usual frame size is 366. next mp3 frame starts from tag offset + usual frame size
	ID3v1 is not expected in the middle of MP3 frames. 
	mono
	
Neverwinter Nights 2 Storm of Zehir soundtrack - maintheme.mp3
	contains broken ID3v1 in the middle of MP3 frames at offset:: 0x00364328, next mp3 frame starts from tag offset + usual frame size
	ID3v1 is not expected in the middle of MP3 frames. 

4. granule big_values > 288, this is not allowed

Avril Lavigne - Here's To Never Growing Up.mp3
	constain bad MP3 frame at offset: 0x000F320B  ( mpa: granule big_values > 288 )
	plays ok

08 - Crush.mp3
	constain bad MP3 frame at offset: 0x0011EC7B ( mpa: granule big_values > 288 )
	plays ok

5. Other

09. Мария Пахоменко - Стоят Девчонки (ill fame Remix).mp3
        error ( mpa: invalid audio buffer signal spec for packet )
	contains ID3v1 at the end at offset: 0x00999EBD but it has only 127 bytes, but should have 128 bytes
	ID3v1 is allowed at the end of the file.
	plays ok

09 - Goddess.mp3
	constain bad MP3 frame at offset: 0x000C5B31 ( mpa: stereo channel pair block_type mismatch )
	plays ok,
	ffmpeg - no errors
	
InFlux Original Soundtrack - 07 - Volcano Dance.mp3
	constain bad MP3 frame at offset: 0x003565CB ( [FAIL] packet=    9045, frame=  10418782 (  47), plane=  0, dec=-0.00000373, ref=+0.00000632 (+0.00001005) )
	a lot of failed packets
	plays ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants