[FFmpeg-user] Set target file size

Takashi ffmpeg-list at dubistmeinheld.de
Tue May 27 15:38:44 CEST 2014

On 05/27/2014 01:04 PM, James Darnley wrote:
> On 2014-05-27 12:49, Takashi wrote:
>> Example calculation (target file size = 8MB):
>> (8 MB * 8192 [converts MB to kilobits]) / 55 seconds = ~1192 kilobits/s
>> total bitrate
>> 1192k - 128k (desired audio bitrate) = 1064k video bitrate
> Wrong.  8MiB = 67108864 bits -> 1220 kb/s

After reading into MiB and MB differences, I do not fully understand
your calculation. Can you please explain?

I agree on:
8MiB = 67108864 bits

67108864 Bit = 65536 Kilobit
65536 Kilobit / 55 seconds = ~1192 Kilobit/s

> Anyway, why are you trying to make the file bigger than the input?

Yes, this does not make sense and was only meant as example.

When I convert a file of of 80.6MiB and set the target file size to
50MiB, I get a file of 47.1MiB. Same ffmpeg command as posted before.

This file reports an error during conversion, maybe this is the reason:
[mp3 @ 0x2a07380] incomplete frame 47769kB time=00:06:57.39 bitrate=
Error while decoding stream #0:1: Invalid data found when processing input

>From my calculations:
$source_file_size: 660464 kilobit
$target_file_size: 409600 kilobit
$file_duration: 420.040000 s
$bitrate_total: 975.14522426436 kilobit
$bitrate_audio: 192 Kbps
$bitrate_video: 783.14522426436 Kbps
Estimated file size: 50 MiB

Just wondering if anyone had success defining a target size that matches
with the calculations, or if this is possible at all.

More information about the ffmpeg-user mailing list