Repository navigation
|
Hi Vanilagy, I occasionally run into A/V sync problems with MP4 files generated in the browser with Mediabunny using HEVC + AAC. Since I can’t share the problem video because of privacy/security restrictions, I only have an AI-assisted analysis to go on, so I’m not fully confident the conclusion is correct. After about 20 seconds of continuous playback, the audio can suddenly be around 1 second ahead of the video in QuickTime/Apple players. It stays out of sync after that, but seeking past that point seems to fix it. The same file plays normally in VLC, and ffmpeg -i input.mp4 -c copy output.mp4 also seems to fix it. The AI-assisted analysis found that the original file has 1,156 chunks and 148 cases where a later chunk in the file starts at an earlier normalized DTS than the previous chunk. The ffmpeg remux has 4,714 chunks and no such cases. Packet timestamps and compressed data appeared unchanged; the main difference was the chunking and physical chunk order. I also had AI try a workaround using roughly 0.125-second chunks and ordering chunks so their normalized DTS increases across tracks. In my testing, that seemed to fix the issue, but I’m not sure whether it addresses the actual root cause. A few questions:
Would be interested to hear your thoughts. Thanks! |
Replies: 3 comments 2 replies
This comment was marked as spam.
This comment was marked as spam.
|
Thanks for bringing this up. I believe the analysis, because nothing else really makes sense. I modified the muxer to behave exactly like this, emitting chunks sorted chronologically, here: 6a65332 I left the default chunk size at 0.5 seconds for now. Why? I just found that that's a common value found in many files, and it's short enough to chunk up the file nicely while not being too short to spam chunks. Anyway. Since I haven't reproduced this bug locally, I need you! Once I release the next Mediabunny version (should be within 8 hours of me writing this comment), see if it fixes it for you. If it does, great; if it doesn't, I might revert the change and we'll need to keep digging. |
|
The change is in https://github.com/Vanilagy/mediabunny/releases/tag/v1.64.0 Let me know if it fixes it. |
The change is in https://github.com/Vanilagy/mediabunny/releases/tag/v1.64.0
Let me know if it fixes it.