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 committed Nov 27, 2023
1 parent bc2f542 commit 8070f0f
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
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
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 8070f0f

Please sign in to comment.