diff --git a/lib/tools/ts-inspector.js b/lib/tools/ts-inspector.js index 8c700a8e..7657c23b 100644 --- a/lib/tools/ts-inspector.js +++ b/lib/tools/ts-inspector.js @@ -220,8 +220,24 @@ var parseVideoPes_ = function(bytes, pmt, result) { i += pes.byteLength; } if (probe.ts.videoPacketContainsKeyFrame(frame)) { - result.firstKeyFrame = probe.ts.parsePesTime(frame); - result.firstKeyFrame.type = 'video'; + var firstKeyFrame = probe.ts.parsePesTime(frame); + + // PTS/DTS may not be available. Simply *not* setting + // the keyframe seems to work fine with HLS playback + // and definitely preferable to a crash with TypeError... + if (firstKeyFrame) { + result.firstKeyFrame = firstKeyFrame; + result.firstKeyFrame.type = 'video'; + } + else { + console.warn( + 'Failed to extract PTS/DTS from PES at first keyframe. ' + + 'This could be an unusual TS segment, or else mux.js did not ' + + 'parse your TS segment correctly. If you know your TS ' + + 'segments do contain PTS/DTS on keyframes please file a bug ' + + 'report! You can try ffprobe to double check for yourself.' + ); + } } currentFrame.size = 0; }