Skip to content

Commit

Permalink
fix: Fix transmuxer when sample has no video data (#5933)
Browse files Browse the repository at this point in the history
Fixes #5931
  • Loading branch information
avelad authored Nov 27, 2023
1 parent 83f6f53 commit 6102060
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/transmuxer/ts_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ shaka.transmuxer.TsTransmuxer = class {
}
}
} catch (e) {
if (e && e.code == shaka.util.Error.Code.TRANSMUXING_NO_VIDEO_DATA) {
return Promise.resolve(new Uint8Array([]));
}
return Promise.reject(e);
}

Expand Down Expand Up @@ -704,6 +707,12 @@ shaka.transmuxer.TsTransmuxer = class {

let nalus = [];
const videoData = tsParser.getVideoData();
if (!videoData.length) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.TRANSMUXING_NO_VIDEO_DATA);
}
for (let i = 0; i < videoData.length; i++) {
const pes = videoData[i];
const dataNalus = pes.nalus;
Expand Down Expand Up @@ -790,6 +799,12 @@ shaka.transmuxer.TsTransmuxer = class {

let nalus = [];
const videoData = tsParser.getVideoData();
if (!videoData.length) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.TRANSMUXING_NO_VIDEO_DATA);
}
for (let i = 0; i < videoData.length; i++) {
const pes = videoData[i];
const dataNalus = pes.nalus;
Expand Down
6 changes: 6 additions & 0 deletions lib/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,12 @@ shaka.util.Error.Code = {
*/
'MSS_TRANSMUXING_FAILED': 3022,

/**
* An internal error which indicates that transmuxing operation has no video
* data. This should not be seen by applications.
*/
'TRANSMUXING_NO_VIDEO_DATA': 3023,


/**
* The Player was unable to guess the manifest type based on file extension
Expand Down

0 comments on commit 6102060

Please sign in to comment.