http-streaming icon indicating copy to clipboard operation
http-streaming copied to clipboard

Out of sync audio with video in fmp4 with different timestampOffset

Open Llorito opened this issue 7 years ago • 1 comments

When we have a hls(fmp4) or dash(fmp4) 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. There is a 0.1 sec out of desyncronization.

I was found the error and fixed it in sync-controller class in 10.5 version . With new 1.11.1 I think the problem persist

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
    };
  }

Here is a example of fmp4 HLS with diferent timestamp: https://frikiluser.github.io/dash-avsync-demo/index.m3u8 (bip sound every 5 absolute seconds...)

Here is a example of fmp4 DASH with diferent timestamp: https://frikiluser.github.io/dash-avsync-demo/index.mpd (bip sound every 5 absolute seconds...)

Check demo: https://jsbin.com/zayulol/edit?html,output

Llorito avatar Nov 06 '19 12:11 Llorito

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.

stale[bot] avatar Feb 18 '20 19:02 stale[bot]