Opened 7 years ago

Closed 6 weeks ago

Last modified 6 weeks ago

#1771 closed defect (fixed)

The file size limit almost never works.

Reported by: agusdallalba 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 follow-up: Changed 7 years ago by cehoyos

  • Component changed from undetermined to documentation
  • Priority changed from normal to minor
  • Reproduced by developer set
  • Status changed from new to open

Imo, this is a documentation issue.

comment:2 Changed 7 years ago by agusdallalba

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

comment:3 in reply to: ↑ 1 ; follow-up: Changed 7 years ago by saste

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.

comment:4 in reply to: ↑ 3 Changed 7 years ago by agusdallalba

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 Changed 6 weeks ago by Gyan

  • Component changed from documentation to ffmpeg

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

comment:6 Changed 6 weeks ago by cehoyos

  • Component changed from ffmpeg to documentation
  • Keywords limit_size removed
  • Resolution set to fixed
  • Status changed from open to closed

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

comment:7 Changed 6 weeks ago by Gyan

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.