Opened 11 years ago

Closed 5 years ago

Last modified 5 years ago

#1771 closed defect (fixed)

The file size limit almost never works.

Reported by: Agustín Dall'Alba Owned by:
Priority: minor Component: documentation
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Just what it says on the tin. I couldn't find a single file-codec combination such that ffmpeg obeys the file size limit imposed with the -fs switch. It always overshoots.

How to reproduce:

  1. Pick any file
  2. Transcode/remux/cut it with ffmpeg while specifying a file size limit with -fs
  3. Measure the size of the resulting file. It's almost always slightly bigger than requested.

Change History (7)

comment:1 by Carl Eugen Hoyos, 11 years ago

Component: undetermineddocumentation
Priority: normalminor
Reproduced by developer: set
Status: newopen

Imo, this is a documentation issue.

comment:2 by Agustín Dall'Alba, 11 years ago

So it's supposed to work this way? Should I make this ticket a feature request then or open a new one?

in reply to:  1 ; comment:3 by Stefano Sabatini, 11 years ago

Replying to cehoyos:

Imo, this is a documentation issue.

IMO, this is a bug. If the user needs this option, it is because she usually has an upper bound size constraint, getting a "slightly bigger" file is not very helpful. Thus the behaviour should be changed.
On the other hand, the additional size may be due to the format trailer, which is not always (easily) predictable, so that may be the reason of the observed behavior.

in reply to:  3 comment:4 by Agustín Dall'Alba, 11 years ago

Replying to saste:

On the other hand, the additional size may be due to the format trailer, which is not always (easily) predictable, so that may be the reason of the observed behavior.

I tried with ffmpeg -i dinah.mp4 -an -f rawvideo -fs xxxx -y out.raw, where dinah.mp4 is a yuv420p 480x360 video. Each frame is (6B/4px)*480*360px = 259200 bytes of raw video. Coincidentally out.raw is always the smallest multiple of 259200 bytes that's bigger than xxxx in the command line.

comment:5 by Gyan, 5 years ago

Component: documentationffmpeg

The documentation was clarified in 9effa012553167d3662f1392310671c575c9322f, so this ticket, if valid, is a ffmpeg bug/limitation.

comment:6 by Carl Eugen Hoyos, 5 years ago

Component: ffmpegdocumentation
Keywords: limit_size removed
Resolution: fixed
Status: openclosed

I don't see how this can be realistically improved, the documentation issue was fixed by Umair.

comment:7 by Gyan, 5 years ago

In theory, one could

1) allow the user to set a trailer size threshold in % terms, or use a hardcoded value.

2) write_packet could abort if current output size + pkt.size + above trailer estimate exceeds the fs limit.

One complication would be missing interim frames for video streams with delay. But that could perhaps be ameliorated by taking into account video_delay from the stream's codecpar.

Note: See TracTickets for help on using tickets.