Closed hey-red closed 2 years ago
I forget about important detail - it's problem with mp3 with cover images. Sample: https://files.catbox.moe/7cz4o9.mp3
Hello @hey-red. I don't remember encountering an issue like this when I originally wrote the code for handling this. If you are interested in potentially fixing this yourself, examine this method. Hope this helps :D
@yodadude2003 I have found that method throws EndOfStreamException while trying to get packet from video stream(mjpeg). That's strange, because with MediaMode.Video it sucessfully read packet from stream. Maybe for mp3 decoder/demuxer needs additional handling.
Huh, that is quite strange indeed. I have an idea, however. I believe the code in that method is erroneously retrieving a packet from a non-existent stream number. If you replace the line in that method: GetPacketFromStream(i)
with GetPacketFromStream(stream->index)
, does it work? If so, I can write up a proper fix to address this issue.
@yodadude2003 Method should works correctly, but I guess order is important in this case. If I try to decode video first it's correctly take first packet with image cover, and both streams is presents in container.
Ah I see @hey-red, good to know! The issue is probably due to this reason: if you read the audio stream first, the file seeks past the first video packet. So when you try to read the video stream afterwards, there are no more packets to read and so it returns empty data. I don't think that's neccisarilly an issue with the library.
@yodadude2003 Yes. It's a just unexpected behavior(for me). I think in future will be good to have an option to ordering streams, that should be loaded, but today I'm just can load file twice.
Sounds good @hey-red. Thanks!
Maybe it's ffmpeg behavior, but when we set MediaMode.AudioVideo(which is default), in streams list we can see only primary stream.
Only way to get information about both video and audio streams is separate opening same file.
MediaFile.Open(input, new MediaOptions { StreamsToLoad = MediaMode.Audio });