Skip to content

🎥 Make videos programmatically with React

add -faststart flag

Jonny Burgerb0422577615e
diff --git a/packages/renderer/src/combine-videos.ts b/packages/renderer/src/combine-videos.ts
index 7f865a80fd..8ead582ac0 100644
--- a/packages/renderer/src/combine-videos.ts
+++ b/packages/renderer/src/combine-videos.ts
@@ -41,6 +41,8 @@ export const combineVideos = async ({
Internals.isAudioCodec(codec) ? null : 'copy',
'-c:a',
getAudioCodecName(codec),
+ codec === 'h264' ? '-movflags' : null,
+ codec === 'h264' ? 'faststart' : null,
'-shortest',
'-y',
output,
diff --git a/packages/renderer/src/prespawn-ffmpeg.ts b/packages/renderer/src/prespawn-ffmpeg.ts
index 9f634f0cbc..3bda3d0505 100644
--- a/packages/renderer/src/prespawn-ffmpeg.ts
+++ b/packages/renderer/src/prespawn-ffmpeg.ts
@@ -91,16 +91,15 @@ export const prespawnFfmpeg = async (options: PreSticherOptions) => {
// -c:v is the same as -vcodec as -codec:video
// and specified the video codec.
['-c:v', encoderName],
- ...[
- proResProfileName ? ['-profile:v', proResProfileName] : null,
- supportsCrf ? ['-crf', String(crf)] : null,
- ['-pix_fmt', pixelFormat],
+ proResProfileName ? ['-profile:v', proResProfileName] : null,
+ supportsCrf ? ['-crf', String(crf)] : null,
+ ['-pix_fmt', pixelFormat],
- // Without explicitly disabling auto-alt-ref,
- // transparent WebM generation doesn't work
- pixelFormat === 'yuva420p' ? ['-auto-alt-ref', '0'] : null,
- ['-b:v', '1M'],
- ],
+ // Without explicitly disabling auto-alt-ref,
+ // transparent WebM generation doesn't work
+ pixelFormat === 'yuva420p' ? ['-auto-alt-ref', '0'] : null,
+ ['-b:v', '1M'],
+ codec === 'h264' ? ['-movflags', 'faststart'] : null,
'-y',
options.outputLocation,
];
diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.ts
index f104d52707..f9171b6425 100644
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@ -261,6 +261,7 @@ export const spawnFfmpeg = async (
// transparent WebM generation doesn't work
pixelFormat === 'yuva420p' ? ['-auto-alt-ref', '0'] : null,
['-b:v', '1M'],
+ codec === 'h264' ? ['-movflags', 'faststart'] : null,
]),
audioCodecName ? ['-c:a', audioCodecName] : null,
// Ignore metadata that may come from remote media