File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @webav/av-recorder ' : patch
3+ ---
4+
5+ fix: av-recorder closing video/audio track export error #335
Original file line number Diff line number Diff line change @@ -242,13 +242,20 @@ function startRecord(
242242 let stopEncodeVideo : TClearFn | null = null ;
243243 let stopEncodeAudio : TClearFn | null = null ;
244244
245+ const [ hasVideoTrack , hasAudioTrack ] = [
246+ opts . streams . video != null ,
247+ opts . streams . audio != null && opts . audio != null ,
248+ ] ;
249+
245250 const recoder = recodemux ( {
246- video : { ...opts . video , bitrate : opts . bitrate ?? 3_000_000 } ,
247- audio : opts . audio ,
251+ video : hasVideoTrack
252+ ? { ...opts . video , bitrate : opts . bitrate ?? 3_000_000 }
253+ : null ,
254+ audio : hasAudioTrack ? opts . audio : null ,
248255 } ) ;
249256
250257 let stoped = false ;
251- if ( opts . streams . video != null ) {
258+ if ( hasVideoTrack ) {
252259 let lastVf : VideoFrame | null = null ;
253260 let autoInsertVFTimer = 0 ;
254261 const emitVf = ( vf : VideoFrame ) => {
@@ -290,7 +297,7 @@ function startRecord(
290297 } ;
291298 }
292299
293- if ( opts . audio != null && opts . streams . audio != null ) {
300+ if ( hasAudioTrack ) {
294301 stopEncodeAudio = autoReadStream ( opts . streams . audio , {
295302 onChunk : async ( ad : AudioData ) => {
296303 if ( stoped ) {
You can’t perform that action at this time.
0 commit comments