Skip to content

Commit 009f769

Browse files
cmacq2gkatsev
authored andcommitted
fix: null check firstKeyFrame in ts-inspector (#251)
Fixes #250
1 parent 7044757 commit 009f769

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/tools/ts-inspector.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,24 @@ var parseVideoPes_ = function(bytes, pmt, result) {
220220
i += pes.byteLength;
221221
}
222222
if (probe.ts.videoPacketContainsKeyFrame(frame)) {
223-
result.firstKeyFrame = probe.ts.parsePesTime(frame);
224-
result.firstKeyFrame.type = 'video';
223+
var firstKeyFrame = probe.ts.parsePesTime(frame);
224+
225+
// PTS/DTS may not be available. Simply *not* setting
226+
// the keyframe seems to work fine with HLS playback
227+
// and definitely preferable to a crash with TypeError...
228+
if (firstKeyFrame) {
229+
result.firstKeyFrame = firstKeyFrame;
230+
result.firstKeyFrame.type = 'video';
231+
} else {
232+
// eslint-disable-next-line
233+
console.warn(
234+
'Failed to extract PTS/DTS from PES at first keyframe. ' +
235+
'This could be an unusual TS segment, or else mux.js did not ' +
236+
'parse your TS segment correctly. If you know your TS ' +
237+
'segments do contain PTS/DTS on keyframes please file a bug ' +
238+
'report! You can try ffprobe to double check for yourself.'
239+
);
240+
}
225241
}
226242
currentFrame.size = 0;
227243
}

0 commit comments

Comments
 (0)