Skip to content

🎥 Make videos programmatically with React

Fix video track timescale when combining chunks

Jonny Burger7631d5a4dfea
diff --git a/packages/renderer/src/combine-video-streams.ts b/packages/renderer/src/combine-video-streams.ts
index 92ad61c733..5375cf27c4 100644
--- a/packages/renderer/src/combine-video-streams.ts
+++ b/packages/renderer/src/combine-video-streams.ts
@@ -63,6 +63,9 @@ export const combineVideoStreams = async ({
'-an',
'-c:v',
encoder,
+ // Keep the MP4/MOV video time base consistent with the initial encoding.
+ '-video_track_timescale',
+ '90000',
codec === 'h265' ? '-tag:v' : null,
codec === 'h265' ? 'hvc1' : null,
addRemotionMetadata ? `-metadata` : null,
diff --git a/packages/renderer/src/mux-video-and-audio.ts b/packages/renderer/src/mux-video-and-audio.ts
index 4c44a599ee..0db3f8f33b 100644
--- a/packages/renderer/src/mux-video-and-audio.ts
+++ b/packages/renderer/src/mux-video-and-audio.ts
@@ -71,6 +71,9 @@ export const muxVideoAndAudio = async ({
// result in slightly imprecise values like 95940000/3197999 instead of 30/1.
videoOutput ? '-r' : null,
videoOutput ? String(fps) : null,
+ // Keep the MP4/MOV video time base consistent with the initial encoding.
+ videoOutput ? '-video_track_timescale' : null,
+ videoOutput ? '90000' : null,
numberOfGifLoops === null ? null : '-loop',
numberOfGifLoops === null
? null