Serial-ATA / lofty-rs

Audio metadata library
Apache License 2.0
187 stars 35 forks source link

Adding picture to OGG Vorbis corrupts file #37

Closed leo60228 closed 2 years ago

leo60228 commented 2 years ago

I tried this code:

                                let mut picture = Picture::from_reader(
                                    &mut File::open(path).context("failed to open picture")?,
                                )
                                .context("failed to create Picture")?;
                                picture.set_pic_type(PictureType::CoverFront);

                                tag.remove_picture_type(PictureType::CoverFront);
                                tag.push_picture(picture);

Describe the bug Adding a picture to an Ogg Vorbis file corrupts it, giving this error from ffmpeg:

[ogg @ 0x1834880] CRC mismatch!
[ogg @ 0x1834880] Header processing failed: Invalid data found when processing input

The same code works for adding pictures to FLAC and MP3, and for adding textual metadata to Ogg Vorbis.

Expected behavior I expected adding a picture to an Ogg Vorbis file to give a valid resulting file, or at least give a proper error.

Assets I'm not able to redistribute the files I'm testing with, I can try to make a standalone reproducer if necessary.

Serial-ATA commented 2 years ago

Hm, I can't reproduce this. What's the size and format of the picture?

leo60228 commented 2 years ago

It's an 82KB 700x700 JPEG.

leo60228 commented 2 years ago

I was able to reproduce the issue with https://homestuck.bandcamp.com/track/purple-tyrant (free download) and https://hsmusic.wiki/media/album-art/coloUrs-and-mayhem-universe-a/purple-tyrant.jpg.

Serial-ATA commented 2 years ago

Thanks! It should be fixed in https://github.com/Serial-ATA/lofty-rs/commit/41e4b1a8835422e8ebeed11b54135a9bbbe2c5a9. Could you try it out?

leo60228 commented 2 years ago

That fixed it, thanks!

Serial-ATA commented 2 years ago

The fix was published in 0.5.3 :)