mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix(video): write faststart mp4/mov output from stabilize-video (#593)
Add -movflags +faststart for mp4/mov/m4v output from stabilize-video so the stabilized result streams and previews progressively instead of appearing broken or corrupted (moov atom was landing after mdat). Fixes #588
This commit is contained in:
@@ -47,6 +47,20 @@ function codecForContainer(ext: string): {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* mp4/mov muxers write the moov atom at the end of the file by default. A
|
||||
* progressive player (browsers, the in-app player, most mobile players) then
|
||||
* cannot start playback or seek until the whole file is downloaded, so the
|
||||
* stabilized result looks broken or "corrupted" on preview. +faststart moves
|
||||
* the moov atom to the front. Mirrors convert-video / compress-video (#588).
|
||||
*/
|
||||
function faststartArgs(ext: string): string[] {
|
||||
const lower = ext.toLowerCase();
|
||||
return lower === ".mp4" || lower === ".m4v" || lower === ".mov"
|
||||
? ["-movflags", "+faststart"]
|
||||
: [];
|
||||
}
|
||||
|
||||
export function registerStabilizeVideo(app: FastifyInstance) {
|
||||
createToolRoute(app, {
|
||||
toolId: "stabilize-video",
|
||||
@@ -98,6 +112,7 @@ export function registerStabilizeVideo(app: FastifyInstance) {
|
||||
`vidstabtransform=input=${trf}:smoothing=${settings.smoothing}`,
|
||||
...encodeArgs,
|
||||
...audioArgs,
|
||||
...faststartArgs(origExt),
|
||||
outPath,
|
||||
],
|
||||
info.durationS,
|
||||
|
||||
Reference in New Issue
Block a user