Skip to content

🎥 Make videos programmatically with React

Preserve WebM alpha and update shared-memory render assertions

Jonny Burger41cd91888386
diff --git a/packages/it-tests/src/rendering/render-scale.test.ts b/packages/it-tests/src/rendering/render-scale.test.ts
index 6a7cce1600..13cf884a68 100644
--- a/packages/it-tests/src/rendering/render-scale.test.ts
+++ b/packages/it-tests/src/rendering/render-scale.test.ts
@@ -33,6 +33,7 @@ test(
'0-1',
'--codec',
'h264',
+ '--log=verbose',
'--scale',
'2',
outputPath,
@@ -42,7 +43,7 @@ test(
},
);
task.stderr?.pipe(process.stderr);
- await task;
+ const result = await task;
const exists = fs.existsSync(outputPath);
expect(exists).toBe(true);
@@ -56,7 +57,10 @@ test(
});
const data = info.stderr;
expect(data).toContain('Video: h264');
- if (NoReactInternals.ENABLE_V5_BREAKING_CHANGES) {
+ if (
+ NoReactInternals.ENABLE_V5_BREAKING_CHANGES ||
+ result.stdout.includes('-f,remotionshm')
+ ) {
expect(data).toContain('yuv420p');
} else {
expect(data).toContain('yuvj420p');
@@ -85,6 +89,7 @@ test(
'0-1',
'--codec',
'h264',
+ '--log=verbose',
'--scale',
'0.1',
outputPath,
@@ -94,7 +99,7 @@ test(
},
);
task.stderr?.pipe(process.stderr);
- await task;
+ const result = await task;
const exists = fs.existsSync(outputPath);
expect(exists).toBe(true);
@@ -108,7 +113,10 @@ test(
});
const data = info.stderr;
expect(data).toContain('Video: h264');
- if (NoReactInternals.ENABLE_V5_BREAKING_CHANGES) {
+ if (
+ NoReactInternals.ENABLE_V5_BREAKING_CHANGES ||
+ result.stdout.includes('-f,remotionshm')
+ ) {
expect(data).toContain('yuv420p');
} else {
expect(data).toContain('yuvj420p');
diff --git a/packages/it-tests/src/rendering/rendering.test.ts b/packages/it-tests/src/rendering/rendering.test.ts
index a8296f6634..cf30791aad 100644
--- a/packages/it-tests/src/rendering/rendering.test.ts
+++ b/packages/it-tests/src/rendering/rendering.test.ts
@@ -549,6 +549,7 @@ test(
'build',
'gif',
'--concurrency=1',
+ '--log=verbose',
'--frames=0-47',
'--muted',
outputPath,
@@ -581,6 +582,10 @@ test(
expect(data).toContain('Video: h264');
if (NoReactInternals.ENABLE_V5_BREAKING_CHANGES) {
expect(data).toContain('bt709');
+ } else if (task.stdout.includes('-f,remotionshm')) {
+ expect(data).toContain(
+ 'yuv420p(tv, unknown/bt709/iec61966-2-1, progressive)',
+ );
} else {
expect(data).not.toContain('bt709');
}
@@ -717,6 +722,7 @@ test(
'build',
'dynamic-duration',
'--concurrency=1',
+ '--log=verbose',
`--props`,
JSON.stringify({duration: randomDuration, offthread: true}),
'--separate-audio-to',
@@ -747,6 +753,10 @@ test(
expect(data).toContain(
`Stream #0:0[0x1](und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive)`,
);
+ } else if (task.stdout.includes('-f,remotionshm')) {
+ expect(data).toContain(
+ `Stream #0:0[0x1](und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, unknown/bt709/iec61966-2-1, progressive)`,
+ );
} else {
expect(data).toContain(
`Stream #0:0[0x1](und): Video: h264 (avc1 / 0x31637661), yuvj420p(pc, bt470bg/unknown/unknown, progressive)`,
diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.ts
index 43db83eafe..b44e78247f 100644
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@ -491,6 +491,13 @@ const innerStitchFramesToVideo = async (
}),
// Ignore metadata that may come from remote media
['-map_metadata', '-1'],
+ // VP8/VP9 store alpha in additional blocks. Stream copying cannot infer
+ // the alpha channel from the decoded pixel format, so retain its signal.
+ preEncodedFileLocation &&
+ (codec === 'vp8' || codec === 'vp9') &&
+ pixelFormat === 'yuva420p'
+ ? ['-metadata:s:v:0', 'alpha_mode=1']
+ : null,
...makeMetadataArgs(metadata ?? {}),
force || fastStartIntermediate ? '-y' : null,
fastStartIntermediate ? ['-f', fastStartMuxer] : null,