🎥 Make videos programmatically with React
@remotion/renderer: Only report stitchStage as 'muxing' when audio is present
copilot-swe-agent[bot]6135e757cc11
diff --git a/packages/docs/docs/renderer/render-media.mdx b/packages/docs/docs/renderer/render-media.mdxindex b675802dfa..d22ca647c1 100644--- a/packages/docs/docs/renderer/render-media.mdx+++ b/packages/docs/docs/renderer/render-media.mdx@@ -276,10 +276,10 @@ import {RenderMediaOnProgress} from '@remotion/renderer';const onProgress: RenderMediaOnProgress = ({renderedFrames, encodedFrames, encodedDoneIn, renderedDoneIn, stitchStage}) => {if (stitchStage === 'encoding') {- // First pass, parallel rendering of frames and encoding into video+ // Rendering frames and encoding into videoconsole.log('Encoding...');} else if (stitchStage === 'muxing') {- // Second pass, adding audio to the video+ // Combining audio with video (only occurs when audio is present)console.log('Muxing audio...');}// Amount of frames rendered into images@@ -299,6 +299,8 @@ const onProgress: RenderMediaOnProgress = ({renderedFrames, encodedFrames, encod:::noteThe `progress` attribute is available from v3.2.17.++The `stitchStage` will be `'encoding'` when rendering and encoding frames into video. It will only be `'muxing'` when audio is actually being combined with video (i.e., when audio is present in the composition and not muted). If no audio is present, `stitchStage` will remain `'encoding'` throughout the entire process.:::### `onDownload?`diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.tsindex 76981c5663..085db9c845 100644--- a/packages/renderer/src/render-media.ts+++ b/packages/renderer/src/render-media.ts@@ -59,6 +59,7 @@ import {shouldUseParallelEncoding} from './prestitcher-memory-usage';import {validateSelectedCodecAndProResCombination} from './prores-profile';import type {OnArtifact} from './render-frames';import {internalRenderFrames} from './render-frames';+import {getShouldRenderAudio} from './render-has-audio';import {disableRepro,enableRepro,@@ -741,6 +742,15 @@ const internalRenderMediaRaw = ({ensureOutputDirectory(absoluteOutputLocation);}+ // Determine if audio will actually be rendered to decide on stitch stage+ const shouldRenderAudio =+ getShouldRenderAudio({+ assetsInfo,+ codec,+ enforceAudioTrack,+ muted: disableAudio,+ }) === 'yes';+const stitchStart = Date.now();return internalStitchFramesToVideo({width: Math.round(actualWidth),@@ -757,7 +767,10 @@ const internalRenderMediaRaw = ({crf,assetsInfo,onProgress: (frame: number) => {- stitchStage = 'muxing';+ // Only set to 'muxing' if audio is actually being combined with video+ if (shouldRenderAudio) {+ stitchStage = 'muxing';+ }// With seamless AAC concatenation, the amount of rendered frames// might be longer, so we need to clamp it to avoid progress over 100%if (preEncodedFileLocation) {