Skip to content

Commit

Permalink
fix: Check if baseTimestamp is NaN (#370)
Browse files Browse the repository at this point in the history
if baseTimestamp is NaN, we do not set the baseTimestamp for the track... This means when video.js http-streaming uses mux.js to transmux from TS to MP4, the probe timestamp results use a 0-based baseMediaDecodeTime and the actual transmux uses a DTS-based baseMediaDecodeTime.

If not doing a partial transmux, this causes video.js to use a start time of 0 (from probe) and an end time of DTS (whatever that is). If DTS happens to be negative, then the duration calculated for the first segment ends up being ~25 hours (close to 2^33, the size of the DTS field)
  • Loading branch information
TylerWilley committed Mar 5, 2021
1 parent bb984db commit b4e61dd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/tools/ts-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ var parseVideoPes_ = function(bytes, pmt, result) {
var adjustTimestamp_ = function(segmentInfo, baseTimestamp) {
if (segmentInfo.audio && segmentInfo.audio.length) {
var audioBaseTimestamp = baseTimestamp;
if (typeof audioBaseTimestamp === 'undefined') {
if (typeof audioBaseTimestamp === 'undefined' || isNaN(audioBaseTimestamp)) {
audioBaseTimestamp = segmentInfo.audio[0].dts;
}
segmentInfo.audio.forEach(function(info) {
Expand All @@ -332,7 +332,7 @@ var adjustTimestamp_ = function(segmentInfo, baseTimestamp) {

if (segmentInfo.video && segmentInfo.video.length) {
var videoBaseTimestamp = baseTimestamp;
if (typeof videoBaseTimestamp === 'undefined') {
if (typeof videoBaseTimestamp === 'undefined' || isNaN(videoBaseTimestamp)) {
videoBaseTimestamp = segmentInfo.video[0].dts;
}
segmentInfo.video.forEach(function(info) {
Expand Down

0 comments on commit b4e61dd

Please sign in to comment.