nschlia / ffmpegfs

FUSE-based transcoding filesystem with video support from many formats to FLAC, MP4, TS, WebM, OGG, MP3, HLS, and others.
https://nschlia.github.io/ffmpegfs/
GNU General Public License v3.0
206 stars 14 forks source link

Variable bitrate outputs #6

Closed Skeen closed 6 years ago

Skeen commented 6 years ago

Hi,

I understand that fixed bitrate makes it possible to calculate the maximum filesize on 'open', so:

  1. Why is this required? - To support seeking?
  2. How much work will it take to support dynamic bitrates?
nschlia commented 6 years ago

Hi,

  1. Modern players are able to seek VBR files without any delays or drawbacks as compared to a constant bit rate file. Actually this only applies to audio, basically to MP3. OGG/MP4/MOV/WMA e.g. are VBR by design.
  2. Enabling VBR for MP3 might be easy (should only be a setting for the encoder), but the size prediction is next to impossible (see below)

As a matter of fact both MP4/OGG audio and audio are VBR. Let me explain why it would not make sense to implement VBR for MP3:

The difference is the approach: MP3 variable bit rate limits the maximum rate to whatever is set, thus if many frames become smaller than this maximum, the file will become smaller over all.

MP4/OGG try to match the selected rate. There is a corridor defined (how high or low the rate might get) and the target is the selected rate as an overall average. This means an easy to compress frames become smaller while more complicated parts get a higher rate (up to the maximum). This creates higher quality, making it also possible to predict the resulting size. At least somewhat accurate (the results tend to be +/- 2 to 4 %).

MP3 variable bit rates would make it impossible to predict the file size. It would require an in depth analysis of the source to find out how large it would get, taking time and CPU load, thus one might as well recode it. The resulting size depends heavily on the contents.

If bandwidth or resulting file size is a concern, MP4 is the better choice anyway. It produces the same quality with about 70% of the bitrate of an MP3.

nschlia commented 6 years ago

Remark: If you do like to have MP3 VBR this could be added. Incorrect file sizes would be no big deal, they show up when the directory is first listed. After a file had been recoded, the real size will be displayed. So when a file is copied, it will have the correct size regardless of what was predicted. If you can live with that I could add VBR.

nschlia commented 6 years ago

Closing this for now. I someone's still interested in VBR mp3, then please reopen or make a pull request and add feel free to add support yourself.