[FFmpeg-user] Get the file size in advance when encoding from one another format

Cecil Westerhof Cecil at decebal.nl
Tue Jun 14 21:05:10 EEST 2022


Sendex Six <sendexsix at gmail.com> writes:

> I've created a simple wrapper for FFmpeg using java and use this in a
> spring boot web application, and everything works fine. But the problem is
> I have this requirement that I need to get the file size of any media
> format in advance from encoding to another format because I need to set the
> Header Content-Length.
>
> I did already search it online. Some of those are confusing, and the others
> don't make sense.
>
> Please help me do this; How do I get the file size in advance if I encode
> any media format to another format so that I can set the Header
> Content-Length in the header. What is the formula for this? I'm new to
> FFMpeg.

I think this is impossible. The best you can get is an indication.
(Which can be way of.)
For example I use a script to make videos smaller. In my experience
the new file size can be between 1/6 and 1/14 of the file size of the
input file.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


More information about the ffmpeg-user mailing list