mangui / flashls

HLS Flash Plugin/Player (Chromeless,OSMF,FlowPlayer,mediaelement.js,video.js,Clappr)
http://www.flashls.org
Mozilla Public License 2.0
751 stars 264 forks source link

option to skip corrupted segments? #429

Open alanra opened 9 years ago

alanra commented 9 years ago

Hi folks. So, we're running into an odd issue with Akamai HDN. If you're not familiar with Akamai HDN, it's a service Akamai provides where you can upload MPEG4s and Akamai will dynamically package them into HLS for you. It uses a fixed segment size, usually 10 seconds per segment. However, there's a known issue in Akamai where if you give a file that's, say, 30.026 seconds long, Akamai will return 3 good 10 second chunks for the first segments, and then a corrupted fourth chunk for the small leftover component.

You can see that in action here:

http://link.theplatform.com/s/LOdVRC/7O8SCwzDlbpZ/master.m3u8?format=redirect&manifest=m3u

This is a 30 second and change asset, and when you look at the video variant, the fourth and final segment is corrupted. Note that this is an HLS v2 configuration, but that isn't the issue: we see the same exact thing in a v3 configuration.

If you play this in an iOS client or Mac Safari, those clients will skip the busted segment and playback can continue. However, with flashls, the following error gets thrown:

[Mon Nov 02 2015 08:58:20 GMT-0800 (Pacific Standard Time)] onError():error code:6 url:http://tpr205471def-vh.akamaihd.net/i/,Tech_Summit_2014_-_UX/632/555/151030_2929503_Cloud_9__Home_for_Halloween_Savings_mpx_896.mp4,.csmil/segment4_0_av.ts?null= message:error parsing fragment, no tag found

And playback stops.

You can repro this by pasting http://link.theplatform.com/s/LOdVRC/7O8SCwzDlbpZ/master.m3u8?format=redirect&manifest=m3u into http://www.flashls.org/latest/examples/chromeless/ and starting playback.

So, there's no expectation flashls could play this, because it's corrupted: but the hope is that flashls could add an "ignore decode errors" mode where if a given segment is bad, it just skips over it to play the next, for parity with iOS. Flashls has great handling for I/O errors (timeouts, 404s), but this isn't an I/O error. And in this case, it's not an option to fix the HLS stream: this is an inherent issue with Akamai HDN whenever the length of the file ends up being a multiple of 10 seconds plus a small fractional component that the HLS returns a bad final segment. It gets ignored in iOS and Mac Safari: we just want it to be optionally ignored in flashls as well.

Thanks, and feel free to add comments if you need additional clarification.

mangui commented 9 years ago

ok just ignoring VoD playlist empty last fragment could do the trick in your case ... but indeed skipping fragment is a better option in that case. this is already done when I/O error are met : https://github.com/mangui/flashls/blob/f607a1c93d206805961fb542a40ab9dfd8c88ee1/src/org/mangui/hls/loader/FragmentLoader.as#L460-L473

I will check how to handle this.

dtniland commented 9 years ago

We put a temporary fix into FragmentLoader._fragLoadCompleteHandler which is extremely focused on our problem but it seems to be working. I would definitely feel more comfortable with any fix that you would provide as I'm sure it would be more general

if (fragData.bytes == null) {
                CONFIG::LOGGING {
                    Log.warn("fragment size is null, invalid it and load next one");
                }
                _levels[_hls.loadLevel].updateFragment(_fragCurrent.seqnum, false);
                _loadingState = LOADING_IDLE;
                return;
            }
//thePlatform code added here:
            if (fragData.bytesLoaded === 16 || fragData.bytesLoaded === 3384)
            {
                CONFIG::LOGGING {
                    Log.warn("fragment is no good -- these bad fragments should only be at the end, so we're completing the load");
                }
                _levels[_hls.loadLevel].updateFragment(_fragCurrent.seqnum, false);
                _loadingState = LOADING_COMPLETED;
                return;
            }
mangui commented 9 years ago

@alanra @dtniland plz recheck with latest flashls/dev it should fix your issue