VBR audio encoding...

General area for talk about ZSNES. The best place to ask for related questions as well as troubleshooting.

Moderator: ZSNES Mods

Post Reply
Sessh
Rookie
Posts: 31
Joined: Mon Aug 16, 2010 9:03 pm

VBR audio encoding...

Post by Sessh »

I was just wondering if there was any way to tweak something to make LAME encode audio with a constant bit rate instead of a variable bit rate? I would want something like 32k CBR audio.

I don't speak the programming language very well, but if this is possible, could someone tell me which lines I would have to edit in zsnesw.cfg and what exactly to change?
kode54
Zealot
Posts: 1140
Joined: Wed Jul 28, 2004 3:31 am
Contact:

Re: VBR audio encoding...

Post by kode54 »

You can change the command line to use a -b <bitrate/1000> like -b 64 for 64kbps, but why would you want to do that? Most video formats now support VBR for both video and audio, and VBR is higher quality as it adjusts to fit the content, rather than encoding with too few or too many bits to meet a hard bitrate.
Sessh
Rookie
Posts: 31
Joined: Mon Aug 16, 2010 9:03 pm

Re: VBR audio encoding...

Post by Sessh »

It's really just a matter of convenience for what I'm trying to do ATM. VirtualDub won't join two AVI's with VBR audio because the sampling rates don't match. I can save them individually with CBR and they join, but then the A/V sync is all messed up. I can work around it, it's just a pain and figured it would be easier if I could get ZSNES to dump CBR from the start. If I record in 13-15 minute chunks, occasionally ZSNES tends to mess up and the character on screen starts doing things I didn't do during playback. This is really why I don't like VBR because of the sync problems.

Thanks for the reply.
Sessh
Rookie
Posts: 31
Joined: Mon Aug 16, 2010 9:03 pm

Re: VBR audio encoding...

Post by Sessh »

md_audio_compress="lame -m j --preset 64 -q 0 - $md_compressed_audio

I'm assuming this is the line I should change?

md_audio_compress="lame -m j -b 32 -q 0 - $md_compressed_audio

Change it like that?
kode54
Zealot
Posts: 1140
Joined: Wed Jul 28, 2004 3:31 am
Contact:

Re: VBR audio encoding...

Post by kode54 »

You might want to use -b 64, since that's closest to what it was already using. Funny that preset 64 doesn't work, considering it's ABR, I think.
Sessh
Rookie
Posts: 31
Joined: Mon Aug 16, 2010 9:03 pm

Re: VBR audio encoding...

Post by Sessh »

I changed it in the zmovie.cfg as it was above except with -b 64 instead of 32 and VirtualDub still recognizes the audio as VBR. I changed that line back to what it was originally. Do you have any other suggestions?
kode54
Zealot
Posts: 1140
Joined: Wed Jul 28, 2004 3:31 am
Contact:

Re: VBR audio encoding...

Post by kode54 »

You'll want to use the -t option too. That disables writing the LAME header to the file, which is ordinarily used for VBR information, as well as gapless information. Since I don't think VirtualDub supports either of those, you can omit that information.

(That header is encoded as a 32kbps audio frame, but is detected and parsed/skipped by supporting players.)
Sessh
Rookie
Posts: 31
Joined: Mon Aug 16, 2010 9:03 pm

Re: VBR audio encoding...

Post by Sessh »

I did that and VirtualDub still says the same thing, but some things were different. When LAME was encoding, it no longer said "average 64k" as the "average" was gone. The error VirtualDub gives is this (in part):

AVI: Variable bitrate (VBR) audio detected. VBR audio in AVI is non-standard and you may encounter sync errors up to 0ms when attempting to extract WAV files or playing in some players.

This is the first time it has said "sync errors up to 0ms" which means no loss of sync. It usually says something like "865ms" or more. I saved my test file with CBR in VirtualDub and it plays with perfect sync. I will try this on a larger file, but seems like it worked. *knocks on wood*

Thanks for your help. Hopefully, it works with big files too!
paulguy
Zealot
Posts: 1076
Joined: Sat Jul 02, 2005 2:01 am
Contact:

Re: VBR audio encoding...

Post by paulguy »

LAME might still be writing some funky headers in there with different bitrates, but you may as well try it.

Think this could be coaxed in to outputting PCM? I know mencoder is capable of it, and better to keep a lossless quality master if you're editing/encoding afterwards. I'm just anal about these things, though.
Maybe these people were born without that part of their brain that lets you try different things to see if they work better. --Retsupurae
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Re: VBR audio encoding...

Post by creaothceann »

Sessh wrote:VirtualDub won't join two AVI's with VBR audio because the sampling rates don't match.
Get AviSynth and a good editor like AvsP.

You can then use VirtualDub(Mod) only for encoding.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
Sessh
Rookie
Posts: 31
Joined: Mon Aug 16, 2010 9:03 pm

Re: VBR audio encoding...

Post by Sessh »

I'm having no trouble with sync anymore, so thanks to Kode54 and others who replied. VirtualDub still says it's VBR, but the sync error is always 0ms now. Since I am also doing voice-over commentary for this walkthrough, I mentioned this forum in it and gave thanks for helping out. Don't know when it will be done, but thanks again for the help!
Post Reply