[FFmpeg-user] Any way to estimate moov_size in mov/mp4?

Bouke / Videotoolshed bouke at videotoolshed.com
Fri Feb 10 13:20:47 EET 2023


> On 10 Feb 2023, at 11:40, Stefan Oltmanns <stefan-oltmanns at gmx.net> wrote:
> 
> Hello,
> 
> ffmpeg allows to set a reserved space for the moov at the beginning of
> the file using the "-moov_size" option.
> This will waste some space, but prevent the (in some cases very
> time-consuming) second pass of "-movflags faststart" if you want to have
> the moov atom at the beginning of the file.
> 
> If the reserved space is too small the moov atom gets written at the end
> from my testing (the documentation seems to be wrong here, it states
> muxing will fail, or why could the produced mov file still be played?).
> 
> Is there any way to properly estimate the moov size? In my use case it
> should be rather simple: PCM audio, DNXHD codec (all-I frames, almost
> CBR), known number of frames.
> As the produced files are very big anyway I don't mind wasting a few MB
> by overestimating.

I don’t get it.
Faststart is for internet / network playing only, when the entire file is not yet available.
If movflags faststart is needed, it should be darn fast as your files ’should’ be fairly small, as they are intended for (relative) low bandwith.
There is NO penalty for having the MOOV atom at the end if a file is local, as parsing all atoms will not take longer than a few secs if the file is local.
Having said that:
Checking the size of the moov atom is relative simple, use ‘any’ atom parser, or render the same file for 1 frame with a scale as small as you can get, with highly compressed sound and use the entire file size for the MOOV atom size (plus a bit).

Hth,

Bouke





More information about the ffmpeg-user mailing list