From d0fd2135acb4f00268b8f60573f190cdab2e6370 Mon Sep 17 00:00:00 2001 From: umbraci Date: Thu, 29 May 2025 22:25:14 +0800 Subject: [PATCH] fix: Compatible with flv video stream decoding without audio --- src/demux/flv-demuxer.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/demux/flv-demuxer.js b/src/demux/flv-demuxer.js index f3681e7..0a491ba 100644 --- a/src/demux/flv-demuxer.js +++ b/src/demux/flv-demuxer.js @@ -363,6 +363,15 @@ class FLVDemuxer { offset += 11 + dataSize + 4; // tagBody + dataSize + prevTagSize } + if (this._hasAudio && this._hasVideo && !this._audioInitialMetadataDispatched) { + // both audio & video, but audio initial meta data still not dispatched + let samples = this._videoTrack.samples; + if (samples.length > 0 && samples[samples.length - 1].dts > samples[0].dts + 3000) { + Log.d(this.TAG, 'we need regard it as video only, last sample: ' + samples[samples.length - 1].dts + ', first sample: ' + samples[0].dts); + this._hasAudio = false; + } + } + // dispatch parsed frames to consumer (typically, the remuxer) if (this._isInitialMetadataDispatched()) { if (this._dispatch && (this._audioTrack.length || this._videoTrack.length)) {