I discovered another fault in the fragment merging code. This is related to issue #167 where it was discovered that "SPS" and "PPS" and other NAL units could be discarded without being processed as a result of the flawed fragment merging code. It is obvious in hindsight, but the duration and compositionTimeOffset options are also being discarded. That is the subject of this issue.
The issue lies primarily in the feed functions in remuxer/h264.js and remuxer/h265.js.
Consider the case where you feed all your frames with a duration and/or compositionTimeOffset, but without the isLastVideoFrameComplete option. The last NAL unit in each data buffer (possibly an incomplete/partial NAL unit) gets stored in the this.remainingData property to be consumed later. However the duration and compositionTimeOffset options that were provided along with that data are not persisted with it.
In the common case where the last NAL unit in each data buffer is the one containing "VCL" (Video Coding Layer) data, this issue effectively causes every frame to be rendered with the wrong duration and compositionTimeOffset. Further, the very first duration and compositionTimeOffset are completely discarded. If you are monitoring the HTML5 video element's progress (e.g. via its currentTime property), it will always appear to be about 1 frame behind and its playback position may not always line up with expected frame timestamps.
An effective workaround for this is to use the new isLastVideoFrameComplete option (which disables the faulty fragment merging code), but anyone who is unaware of this new option will get video playback that kind of mostly works but has persistent timing errors.
I discovered another fault in the fragment merging code. This is related to issue #167 where it was discovered that "SPS" and "PPS" and other NAL units could be discarded without being processed as a result of the flawed fragment merging code. It is obvious in hindsight, but the
durationandcompositionTimeOffsetoptions are also being discarded. That is the subject of this issue.The issue lies primarily in the
feedfunctions in remuxer/h264.js and remuxer/h265.js.Consider the case where you
feedall your frames with adurationand/orcompositionTimeOffset, but without theisLastVideoFrameCompleteoption. The last NAL unit in eachdatabuffer (possibly an incomplete/partial NAL unit) gets stored in thethis.remainingDataproperty to be consumed later. However thedurationandcompositionTimeOffsetoptions that were provided along with that data are not persisted with it.In the common case where the last NAL unit in each
databuffer is the one containing "VCL" (Video Coding Layer) data, this issue effectively causes every frame to be rendered with the wrongdurationandcompositionTimeOffset. Further, the very firstdurationandcompositionTimeOffsetare completely discarded. If you are monitoring the HTML5 video element's progress (e.g. via itscurrentTimeproperty), it will always appear to be about 1 frame behind and its playback position may not always line up with expected frame timestamps.An effective workaround for this is to use the new
isLastVideoFrameCompleteoption (which disables the faulty fragment merging code), but anyone who is unaware of this new option will get video playback that kind of mostly works but has persistent timing errors.