From 610206002838157658bdadb608588c4430cf075d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Mon, 27 Nov 2023 10:28:14 +0100 Subject: [PATCH] fix: Fix transmuxer when sample has no video data (#5933) Fixes https://github.com/shaka-project/shaka-player/issues/5931 --- lib/transmuxer/ts_transmuxer.js | 15 +++++++++++++++ lib/util/error.js | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/lib/transmuxer/ts_transmuxer.js b/lib/transmuxer/ts_transmuxer.js index 4f6b1dab97..6a9e33c230 100644 --- a/lib/transmuxer/ts_transmuxer.js +++ b/lib/transmuxer/ts_transmuxer.js @@ -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); } @@ -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; @@ -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; diff --git a/lib/util/error.js b/lib/util/error.js index 1c4f5d2e5b..53aa24c0b8 100644 --- a/lib/util/error.js +++ b/lib/util/error.js @@ -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