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

dr_flac: Slow Seeking With Ogg Container #231

Open
MikuAuahDark opened this issue May 7, 2022 · 3 comments
Open

dr_flac: Slow Seeking With Ogg Container #231

MikuAuahDark opened this issue May 7, 2022 · 3 comments

Comments

@MikuAuahDark
Copy link

Seeking with native container is fast, but with Ogg container it's slow. The slowdown seems to be linear, the further I seek, the slower it becomes.

To test, first encode a file using FFmpeg to native FLAC.

ffmpeg -i input -c:a flac -compression_level:a 11 output.flac

Then perform remux to Ogg. This is important to preserve the totalPCMFrameCount in the STREAMINFO block, otherwise totalPCMFrameCount is 0 and seeking is not possible. (probably FFmpeg defect)

ffmpeg -i output.flac -c:a copy output.ogg

Then load output.ogg and perform seek. If you test output.flac, seeking is fast.

dr_flac 0.12.38.

@mackron
Copy link
Owner

mackron commented May 8, 2022

Yes, Ogg seeking runs in linear time. The most efficient way to do it is to use Ogg's framing system to do a binary search, but I just haven't prioritized refactoring it because Ogg encapsulation is so uncommon and dr_flac's encapsulation system is not implemented very well at all which makes maintenance difficult (Ogg support was sort of hacked in without much thought put into it). I need to do a full refactor of the encapsulation system.

@MikuAuahDark
Copy link
Author

MikuAuahDark commented May 8, 2022 via email

@mackron
Copy link
Owner

mackron commented May 8, 2022

No, that wouldn't work. I won't add support for libogg integration into the library itself because it's supposed to not have any dependencies. And unfortunately the public API doesn't have any kind of abstraction where you could plug in a custom encapsulation. It's just an unfortunate situation where the library wasn't designed properly for it and it just needs refactoring. In my WIP dr_vorbis project I have proper support for custom encapsulations at the public API level, so depending on how that works out I may update dr_flac to use the same kind of system. That will be ages away before I get to that though.

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

No branches or pull requests

2 participants