-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support multiplexed streams in HLS start time probe #1194
Comments
@michellezhuogg could you take a look at this issue as you are more familiar with the trans-muxing code? |
The problem is this is using multiplexed content (a stream with both audio and video). Also, the audio and video streams don't start at the same time. We use the first packet to get the time, but the other stream (which appears later) starts before that packet. Some browsers don't support multiplexed content and require the streams to be separate; we usually only support separate streams, but don't explicitly forbid multiplexed streams. It may be possible for this to happen for non-multiplexed streams as well. A media segment doesn't have to start with a key frame. If it starts with a B-frame, then the PTS times of the frames will be out of order. We should parse the first few frames until we hit a key frame to avoid this. But that won't help your stream, since the problem is that there are multiple streams within the TS packet stream. If we see that it is a multiplexed stream (which I think we will always know), then we can probe further to find the second stream, but it may require a second download probe to get the timestamps. |
I think it is maybe a combination of the multiple streams and the fact the timestamp from the first PES packet is used, and the issue I detailed above. This is just an experiment and not really a suggestion, that parses through more than one PES packet to try to find the earlier PTS: It succeeds on the clip I provided above (Probably a more robust strategy would be required in reality), but it still fails with the same MediaSourceExtension errors due to the setBaseMediaDecodeTime not being set correctly. |
I think that issue is a problem with Chrome. Chrome confuses PTS/DTS times, so if we use the PTS times as the offset, the DTS may become negative. This is technically a bug in Chrome that they are actively working on, but we should still support this case. Unfortunately the fix is to use DTS times, which may cause a gap at the beginning of the stream, but gap jumping should be able to compensate for that. |
Actually I think it is a problem with how we are adjusting the times. The segment we get from muxjs has been adjusted to start at 0, but we also use |
When mux.js 4.3.3 comes out, we will have an option to keep the original TS timestamps. However, there is also an issue with your content:
The last segment has a duration of 0, which is not valid. Even with the fix to mux.js, your content will not play because of that. |
Just as an Update. mux.js has been updated yesterday to v4.4.0. |
Yes, and we will be updating to that shortly. |
The updated mux.js does not seem to fix the negative DTS issue. However, the rejection of segments with positive PTS with negative DTS is definitely a Chrome bug (http://crbug.com/398141). It can be fixed by the Chrome experimental flag |
The label "bad content" is for the 0-length segment at the end. |
Depended on issue videojs/mux.js#168 Issue #1194 Change-Id: Ia2ad5c17ad82a2c53215d34fbfec7be1d119df95
The mux.js update is complete. @thedracle, can you fix the 0-length segment in your content? |
Yes, I'll generate a new clip, it's something to do with how FFMPEG is generating those segments from the clip I provided, and test again. |
Here is a HLS clip with similar encoding, that doesn't have the zero duration issue: |
Excellent! With the latest Shaka Player and the Chrome flag I mentioned before, the new clip is working. I will continue to follow-up with Chrome team on this issue. |
Depended on issue videojs/mux.js#168 Issue #1194 Change-Id: Ia2ad5c17ad82a2c53215d34fbfec7be1d119df95
mux.js v4.4.0 update cherry-picked to Shaka Player v2.3.1. |
What version of Shaka Player are you using*
Latest from master.
Can you reproduce the issue with our latest release version:
Latest release does not support muxjs transmuxing.
Can you reproduce the issue with the latest code from
master
:Yes
Are you using the demo app or your own custom app:
Both.
If custom app, can you reproduce the issue using our demo app:
Yes
What browser and OS are you using:
OSX/Chrome
What are the manifest and license server URIs:
(you can send the URIs to shaka-player-issues@google.com instead, but please use GitHub and the template for the rest)
This probably isn't the sample I analyzed below, but it illustrates the same issue.
https://shakarepro.s3-us-west-1.amazonaws.com/repro/mbr/manifest.m3u8
What did you do?
Attempted to play the above HLS stream.
What did you expect to happen?
For it to play.
What actually happened?
I am seeing this issue where the timestamps output by muxjs are different than my TS segments when the presentationTimeOffset isn't 0.
Basically my first MPEGTS segment starts at 133500:
In the logs I see:
Which matches the first PTS (Although there is an earlier PTS for the first audio packet in the stream which appears later).
The presentationTimeOffset is set to 1.4833333333333334, but the code to adjust the PTS via the transmuxer sets it to adjust by 0:
lib/media/transmuxer.js:
^ Tracing in the debugger 'startTime' is 0.
As a result the transmuxed mp4 seems to adjust all of the timestamps:
And MediaSourceExtensions croaks with the following error:
Also, I wonder if getStartTimeFromTsSegment_ in lib/hls/hls_parser.js needs to be adjusted to search for a minimum timestamp closer to the beginning of the TS stream, rather than just reading the PTS out of the first TS packet it finds that has one.
The text was updated successfully, but these errors were encountered: