HydrogenAudio

Lossy Audio Compression => Other Lossy Codecs => Topic started by: Sensei-Hanzo on 2011-08-12 02:23:27

Title: Encoding for a specific file size
Post by: Sensei-Hanzo on 2011-08-12 02:23:27
Hi, I was wondering if there's any way to encode something in MP2 and have it come out to be a specific file size without a whole lot of trial and error. I'm trying to mod League of Legends to replace some voice files with new ones and I have it mostly figured out, but it's not working quite right. For instance, it will start playing some lines in the middle and then run into other lines at the end. The voice files are stored in a .fsb and I suspect it has something to do with the fact that the new files I'm inserting aren't the same size/length as the originals and therefore the offset isn't correct.  To fix it I would need to have the new clips be exactly or nearly exactly the same length as the originals, which takes me back to my original question. I know practically nothing about .fsb files so this is pretty much purely speculation.  Does anyone have a good way to do this or more information on how .fsbs work?

Thanks in advance.

(Note: I'm encoding it in MP2 simply because this guide (http://leaguecraft.com/strategies/gameguide/240-sound-modification-part-the-second.xhtmll) said to. Other common file types may work as well)
Title: Encoding for a specific file size
Post by: klonuo on 2011-08-12 03:52:21
Quote
Hi, I was wondering if there's any way to encode something in MP2 and have it come out to be a specific file size without a whole lot of trial and error.


It's simple math:

Let's say you have track length of 1h 02m, which in seconds is equal to:

T = 1x60x60 + 2x60 = 3720 seconds

Than lets assume we have limited storage of 150 MB, which we calculate in bytes:

S = 150x1024x1024 = 157286400 bytes

and we need this number in bits, which is bytes multiplied by 8, so we have:

S = 157286400x8 = 1258291200 bits

Now we can calculate target bitrate and set encoder to it:

B = S/T = 338250 b/s

or

B = 338250/1024 ~ 330 Kb/s

So we can set encoder with anything lower than 330 Kb/s in that limited space
Title: Encoding for a specific file size
Post by: Sensei-Hanzo on 2011-08-12 04:29:14
Is there a specific encoder or program you could suggest for this? The one I was using just has a "quality" option that ranges from 0-100, which doesn't seem very useful.
Title: Encoding for a specific file size
Post by: saratoga on 2011-08-12 04:56:37
Is there a specific encoder or program you could suggest for this? The one I was using just has a "quality" option that ranges from 0-100, which doesn't seem very useful.


twolame is considered a pretty good mp2 encoder. 

That said, I suspect that whatever software you're using isn't meant for mp2 if its giving you choices between 0-100.
Title: Encoding for a specific file size
Post by: Sensei-Hanzo on 2011-08-12 17:05:47
Hm, it turns out the issue is actually that the fsb repacker I was using doesn't work right. Thanks to the people who replied, though.