dmk
6th March 2014, 08:38
So I've got this sortof pseudostreaming server working, but very often in my tests the audio/video is not sync'd. I can reproduce a situation where the audio is coming in about a full second or two late.
Any ideas where I should look? It seems that interleaving has something to do with it since re-encoding the video or adjusting it with mp4box -inter DOES have an affect. I haven't been able to completely eliminate the delay with that, and I don't like the unpredictability going on, but maybe that's useful info.
This is for a controlled situation where I can generate the videos needed (no need to support everything the wild- but it must be h.264)
On one foot, here's the sortof approach the pseudostreaming server is doing:
1) In trak with i-frames (video), find keyframe sample nearest to requested time
2) In trak without i-frames (audio) find sample which comes immediately after file-offset of video keyframe sample
3) Chop off mdat data to start at file-offset of video keyframe sample.
4) Patch stbl to reflect new start samples and new mdat size
5) Output new header and mdat
Note that jumping around, seeking, everything is working, so I assume the above methodology is pretty much the way to go? It's just the sync which is off at times, and sometimes it is on :\
Any ideas where I should look? It seems that interleaving has something to do with it since re-encoding the video or adjusting it with mp4box -inter DOES have an affect. I haven't been able to completely eliminate the delay with that, and I don't like the unpredictability going on, but maybe that's useful info.
This is for a controlled situation where I can generate the videos needed (no need to support everything the wild- but it must be h.264)
On one foot, here's the sortof approach the pseudostreaming server is doing:
1) In trak with i-frames (video), find keyframe sample nearest to requested time
2) In trak without i-frames (audio) find sample which comes immediately after file-offset of video keyframe sample
3) Chop off mdat data to start at file-offset of video keyframe sample.
4) Patch stbl to reflect new start samples and new mdat size
5) Output new header and mdat
Note that jumping around, seeking, everything is working, so I assume the above methodology is pretty much the way to go? It's just the sync which is off at times, and sometimes it is on :\