From 677a88328fbbd33470059dc2f7ad63a1db3be3e8 Mon Sep 17 00:00:00 2001 From: mahuangyu <1262595717@qq.com> Date: Thu, 28 Nov 2024 16:26:59 +0800 Subject: [PATCH 1/5] fix: av-recorder closing video/audio track export error --- packages/av-recorder/src/av-recorder.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/av-recorder/src/av-recorder.ts b/packages/av-recorder/src/av-recorder.ts index 7a398e03..fbab674b 100644 --- a/packages/av-recorder/src/av-recorder.ts +++ b/packages/av-recorder/src/av-recorder.ts @@ -242,13 +242,20 @@ function startRecord( let stopEncodeVideo: TClearFn | null = null; let stopEncodeAudio: TClearFn | null = null; + const [enableVideo, enableAudio] = [ + opts.streams.video != null, + opts.streams.audio != null, + ]; + const recoder = recodemux({ - video: { ...opts.video, bitrate: opts.bitrate ?? 3_000_000 }, - audio: opts.audio, + video: enableVideo + ? { ...opts.video, bitrate: opts.bitrate ?? 3_000_000 } + : null, + audio: enableAudio ? opts.audio : null, }); let stoped = false; - if (opts.streams.video != null) { + if (enableVideo) { let lastVf: VideoFrame | null = null; let autoInsertVFTimer = 0; const emitVf = (vf: VideoFrame) => { @@ -290,7 +297,7 @@ function startRecord( }; } - if (opts.audio != null && opts.streams.audio != null) { + if (opts.audio != null && enableAudio) { stopEncodeAudio = autoReadStream(opts.streams.audio, { onChunk: async (ad: AudioData) => { if (stoped) { From bdc775142affe2b6a9e76116b7ac7189cfbc11c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E7=97=95?= Date: Thu, 28 Nov 2024 18:27:45 +0800 Subject: [PATCH 2/5] Update av-recorder.ts chore: rename symbol --- packages/av-recorder/src/av-recorder.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/av-recorder/src/av-recorder.ts b/packages/av-recorder/src/av-recorder.ts index fbab674b..6b21d5f3 100644 --- a/packages/av-recorder/src/av-recorder.ts +++ b/packages/av-recorder/src/av-recorder.ts @@ -242,20 +242,20 @@ function startRecord( let stopEncodeVideo: TClearFn | null = null; let stopEncodeAudio: TClearFn | null = null; - const [enableVideo, enableAudio] = [ + const [hasVideoTrack, hasAudioTrack] = [ opts.streams.video != null, - opts.streams.audio != null, + opts.streams.audio != null && opts.audio != null, ]; const recoder = recodemux({ - video: enableVideo + video: hasVideoTrack ? { ...opts.video, bitrate: opts.bitrate ?? 3_000_000 } : null, - audio: enableAudio ? opts.audio : null, + audio: hasAudioTrack ? opts.audio : null, }); let stoped = false; - if (enableVideo) { + if (hasVideoTrack) { let lastVf: VideoFrame | null = null; let autoInsertVFTimer = 0; const emitVf = (vf: VideoFrame) => { @@ -297,7 +297,7 @@ function startRecord( }; } - if (opts.audio != null && enableAudio) { + if (hasAudioTrack) { stopEncodeAudio = autoReadStream(opts.streams.audio, { onChunk: async (ad: AudioData) => { if (stoped) { From bdeb368a8ea8150be81bb90a8b92e5caec620993 Mon Sep 17 00:00:00 2001 From: mahuangyu <1262595717@qq.com> Date: Fri, 29 Nov 2024 13:52:32 +0800 Subject: [PATCH 3/5] feat: add changesets --- packages/av-recorder/.changeset/config.json | 11 +++++++++++ packages/av-recorder/.changeset/mean-grapes-bow.md | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 packages/av-recorder/.changeset/config.json create mode 100644 packages/av-recorder/.changeset/mean-grapes-bow.md diff --git a/packages/av-recorder/.changeset/config.json b/packages/av-recorder/.changeset/config.json new file mode 100644 index 00000000..8639ae56 --- /dev/null +++ b/packages/av-recorder/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.1/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/packages/av-recorder/.changeset/mean-grapes-bow.md b/packages/av-recorder/.changeset/mean-grapes-bow.md new file mode 100644 index 00000000..19e18db1 --- /dev/null +++ b/packages/av-recorder/.changeset/mean-grapes-bow.md @@ -0,0 +1,5 @@ +--- +'@webav/av-recorder': major +--- + +fix bug #335 From a2e567bdd0f922c5437cda383ef5de8633ef88f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E7=97=95?= Date: Fri, 29 Nov 2024 17:30:10 +0800 Subject: [PATCH 4/5] Update mean-grapes-bow.md --- packages/av-recorder/.changeset/mean-grapes-bow.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/av-recorder/.changeset/mean-grapes-bow.md b/packages/av-recorder/.changeset/mean-grapes-bow.md index 19e18db1..6fa2eb56 100644 --- a/packages/av-recorder/.changeset/mean-grapes-bow.md +++ b/packages/av-recorder/.changeset/mean-grapes-bow.md @@ -1,5 +1,5 @@ --- -'@webav/av-recorder': major +'@webav/av-recorder': patch --- -fix bug #335 +fix: av-recorder closing video/audio track export error #335 From 5780270abe557d7338be2ded5447d7289ea45aa2 Mon Sep 17 00:00:00 2001 From: hughfenghen Date: Fri, 6 Dec 2024 11:38:17 +0800 Subject: [PATCH 5/5] chore: move changeset file --- .../.changeset => .changeset}/mean-grapes-bow.md | 0 packages/av-recorder/.changeset/config.json | 11 ----------- 2 files changed, 11 deletions(-) rename {packages/av-recorder/.changeset => .changeset}/mean-grapes-bow.md (100%) delete mode 100644 packages/av-recorder/.changeset/config.json diff --git a/packages/av-recorder/.changeset/mean-grapes-bow.md b/.changeset/mean-grapes-bow.md similarity index 100% rename from packages/av-recorder/.changeset/mean-grapes-bow.md rename to .changeset/mean-grapes-bow.md diff --git a/packages/av-recorder/.changeset/config.json b/packages/av-recorder/.changeset/config.json deleted file mode 100644 index 8639ae56..00000000 --- a/packages/av-recorder/.changeset/config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "https://unpkg.com/@changesets/config@3.0.1/schema.json", - "changelog": "@changesets/cli/changelog", - "commit": false, - "fixed": [], - "linked": [], - "access": "restricted", - "baseBranch": "main", - "updateInternalDependencies": "patch", - "ignore": [] -}