-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ignore buffered packet data with no pes header #378
Conversation
I can confirm that this fixes the issue. Though, having a bit of trouble wrapping my head around the issue. |
The first three packets are PES packets, they are just continued frame data from the last frame in |
Thanks, that makes sense. Wouldn't we want to keep those if we are progressing properly through the segments? Or would we pick those up because we have the data from the previous segment? |
I'm not sure honestly. This was the dilemma I was trying to figure out. Let's say we are at segment |
Thanks, I'll try it out today. I also asked @gesinger to take a look because he knows a lot more about the internals of things than I do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to approve this as pes is required to start with 0x00, 0x00, 0x01
. The reason this happens is that we don't account for SDT
packets in our code so an SDT
packet makes it all the way to parsePes
, where it would obviously mess everything up. Long term we should fix the root cause.
I agree. I think the correct solution would be including those extra PES packets of video data instead of throwing it away but that would be more complicated. |
Description
This is a fix for ts files that carry PES packets of framed data from the previous ts fragment. This addresses the
ERROR: (CODE:3 MEDIA_ERR_DECODE)
for the causeor
Content
The stream I was able to reproduce the bug with is https://e3e2p5m2.ssl.hwcdn.net/hls/main.m3u8. I was able to record when the bug occurred and uploaded the recorded content to https://drive.google.com/drive/folders/174ef0f6DOdMaXI6f3CLYSw_9H5emxzM0?usp=sharing. There is a generated VOD manifest for the recorded content.
Steps to reproduce
I was able to produce this bug using Video.js (v7.11.4).
If you try to playback the content, you can trigger the bug when the player changes bitrates from segment
segment51788.ts @5-1280x720
to segmentsegment51788.ts @0-1920x1080
. Another way to quickly see this is by commenting out all the playlists besides0-1920x1080
and comment out segmentssegment51786.ts
andsegment51787.ts
. This is will generate an incorrect init segment. The corrupted generated init segment has an sps that is incorrect. The width and height are 96 X 96 when the content is really 1920 X 1080. The avcC box has incorrect properties that looks like thiswhen the codec profile and level values should be
Issue
This is happening because in fragment
segment51788.ts @0-1920x1080
, its first 3 ts packets are video pes packets that are continue frame data from the previous fragment. So those 3 PES packets have been buffered and when the nextpayload_unit_start_indicator
comes by, it flushes those packets and assumes there is a PES header and when it's pushed to the NalByteStream it incorrectly sees an sps and creates the incorrect config from there.Solution
The solution I came up with is when the buffered PES packets are flushed to the be parsed, it will check for the first three bytes of the data payload for the start prefix (0x000001) and it will ignore the payload the return an empty
Uint8Array
.