Skip to content

Commit

Permalink
fix: null check firstKeyFrame in ts-inspector (#251)
Browse files Browse the repository at this point in the history
Fixes #250
  • Loading branch information
cmacq2 authored and gkatsev committed Mar 28, 2019
1 parent 7044757 commit 009f769
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/tools/ts-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// eslint-disable-next-line
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;
}
Expand Down

0 comments on commit 009f769

Please sign in to comment.