http-streaming
http-streaming copied to clipboard
Out of sync audio with video in fmp4 with different timestampOffset (possible fix)
When we have a hls with a separate video channel and an audio channel, if they have different segments timestamp offset value (it is possible), it does not play correctly. Both are out of sync.
I have found the error and fixed it in sync-controller class.
probeMp4Segment_(segmentInfo) {
let segment = segmentInfo.segment;
let timescales = mp4probe.timescale(segment.map.bytes);
let startTime = mp4probe.startTime(timescales, segmentInfo.bytes);
if (segmentInfo.timestampOffset !== null) {
segmentInfo.timestampOffset -= startTime;
if (segment.map.videoTrackIds.length > 0) {
//It is Video segment
this.syncOffset = segmentInfo.timestampOffset;
} else {
//It isn't Video segment
if (segmentInfo.timestampOffset !== this.syncOffset) segmentInfo.timestampOffset = this.syncOffset;
}
}
return {
start: startTime,
end: startTime + segment.duration
};
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.