Log in

View Full Version : Encoding from LAME to MPEG Layer-3


twipley
25th June 2010, 17:08
Hello everybody. I'm kind of new to VirtualDub. Recently, I've encoded videos using LAME MP3 as the audio codec. This produced audio delays when played back on the PC, but not when played back on the DVD player (thread: http://forum.doom9.org/showthread.php?p=1410735). At first, I thought that the LAME MP3 option was coming from VirtualDub itself, and not from K-Lite. To fix the issue, I believe (this may not be an informed opinion, as I am kind of new to all this encoding stuff) I will have to re-encode the fully cut-edited videos, unfortunately already encoded to LAME MP3, this time using the "MPEG Layer-3" option for audio. However, in VirtualDub options, I must switch from LAME's 32KB/s to MPEG Layer-3's 7KB/s.

Do you guys think such a significantly reduced bit rate would reveal itself an issue concerning audio quality? The conversion would be directly from LAME ("22050 Hz, 256 kbps ABR, stereo" -- that is, the highest setting available) to the highest (that is, "56 kBit/s, 22 050 Hz, Stereo") available setting for MPEG Layer-3.

So, would something important possibly be lost there in terms of audio quality, keeping in mind that the LAME encoding the second encoding came from was of the highest quality?

P.S.: I have no ready access to the source files, nor those are edited using the (lengthy process) cutting method I have used (VirtualDub).

Thanks,
twipley

Blue_MiSfit
25th June 2010, 17:23
The MP3 encoder included with Windows is very limited, and is extremely poor quality. LAME exposes all the capabilities of the MP3 format.

If you're having sync issues, I'd suggest doing one of the following:

1) Encoding your MP3 audio with LAME using CBR, not ABR/VBR. The AVI container has issues with VBR audio, and working around them requires a series of hacks. These hacks are mostly supported in most places, but not everywhere!
2) Muxing your audio and video into an MP4 or MKV container, as these containers properly support VBR audio (among other features AVI officially does not).

I'm surprised you're seeing sync problems on the PC, and not on your hardware player. I would certainly expect the opposite!

What software player do you use? K-Lite is a powerful tool, provided you're using a recent version and have it configured correctly. If either (or both) of these is not the case, you can run into a lot of DirectShow problems. To sidestep this issue, you can try a media player that doesn't rely on DirectShow, like the extremely popular VLC.

Finally, regarding audio quality - 22KHz usually sounds pretty bad :) If your source material is sampled at 22KHz, then you're out of luck, and this is as good as it gets. Spending 256kbps on such a low quality source is a poor idea. You shouldn't lose much more perceptible quality with bitrates as low as 96kbps CBR for stereo. In fact, this bitrate is "enough" for most folks even at the more common 44.1 KHz / 48KHz!

Looking at your other thread, it seems like you had issues accessing LAME from within VirtualDub. What you need is the LAME ACM codec http://www.free-codecs.com/download/lame_acm_codec.htm. Alternatively, you can use any standalone application that supports LAME encoding like Foobar2000 or LameDrop to output an elementary MP3 file. You can then mux this with your video-only AVI from VirtualDub. If you must use the AVI container for your hardware player, I'd suggest using AVIMuxGUI. Otherwise YAMB or MKVMergeGUI are great tools for MP4 and MKV muxing, respectively.

If you're still having issues, please post a source fragment and we can help you diagnose the patient more thoroughly :)

Derek

twipley
25th June 2010, 19:05
Hey Derek,

Thanks for the insightful post. It helped some things to become clearer in my head. However, there are still some points I'd like, if you wish, to share and discuss with you:

C1) Good to know LAME is an appropriate way to go.

Q1) "Encoding with CBR as a way to avoid sync issues." -- Accessing "LAME MP3" under VirtualDub's audio compression window, the CBR choices are left inaccessible! They seem only to be under higher sampling rates (than 22KHz). I have installed "LAME ACM" like you said, but nothing new appeared in VirtualDub, it seems. I was already included in K-Lite, I think.

C2) "I'm surprised you're seeing sync problems on the PC, and not on your hardware player. I would certainly expect the opposite!" -- Same over here. Latest K-Lite (full) installed using default settings suffers from sync problems -- as does VLC when used in conjunction with those media files.

Q2) Suppose I go with the (as you suggested) "96kbps CBR for stereo." Having no ready access to the original source files, do you think I would suffer from a significant degradation in audio quality using the already 256kbps-converted LAME files as an input (=source files) for conversion instead of the original ones? Or perhaps I should just listen with my ears and not worry if I cannot differ between the two. :)

Thanks,
twipley

P.S.: If you are curious concerning the sync problems on VLC/MPC, I could consider sharing with you an excerpt of those media files -- privately, though, as my preference is not to let those "patient" files circulating in the wild.

EDIT: original codec-guide topic url: http://codecs.freeforums.org/post14186.html

clsid
25th June 2010, 22:10
VBR audio normally works fine with MPC and VLC. But nevertheless try a CBR encoding as suggested above.

Not sure it is related to the problem, but MP3 audio is typically encoded at 44100 Hz. So see if resampling your audio in VirtualDub make any difference.

twipley
28th June 2010, 14:34
Eureka: that seems to have fixed it. CBR indeed seems the way to go under the constraints of the AVI container. /thanks to clsid and Derek.

Indeed have I discovered that one has to do a sampling-rate conversion before effecting such a conversion to higher sampling rates (so that the CBR option can get unlocked).

The only thing that for me still remains hazy is the question of audio quality: going for "44100 Hz Stereo CBR," how much kbps would be necessary for the preservation of audio quality?

My wish being to avoid potential degradations in audio quality, my eyes currently are geared towards the 320. Is this really overkill? Would the audio stay as much preserved at 256, 192, or even 128, kbps?

Midzuki
28th June 2010, 16:19
My wish being to avoid potential degradations in audio quality, my eyes currently are geared towards the 320. Is this really overkill? Would the audio stay as much preserved at 256, 192, or even 128, kbps?

In case of doubt, stick to 224kbps. But if this happens to be "not good enough", no problem in using 320kbps. You know, HDDs and DVD-Rs are cheaper than ever. :devil: ;) :)

twipley
28th June 2010, 16:55
You know, HDDs and DVD-Rs are cheaper than ever.:)...

twipley
29th June 2010, 22:25
I've just spent a some time over at the nice and expansive Hydrogenaudio Forums. There, two options have been offered to me:

1) resampling (to unlock vd's CBR encoding) and CBR reencode using virtualdub, but that might, as some suggested, result in audio-quality loss;

2) outputing audio through "audio > direct stream copy; file > export > raw audio," video through "audio > no audio; video > direct stream copy; file > save as avi," both using virtualdub, then, secondly, using mp3packer to "faithfully convert [i.e. without re-encoding] from VBR to CBR, basically just by padding every frame with 0s" (doing "-b #" using what "--ib" prints out), and, finally, remuxing audio (coming from mp3repacker) together with video (coming from virtualdub) to a final-product AVI file using AVI-Mux GUI.

Thus, needed software:
- virtualdub
- mp3packer
- avimuxgui

EDIT: note that AVI containers have the advantage of being readable on all DivX-compatible DVD players. Otherwise, more modern ones such as MP4/MKV should best be used.

lordadmira
2nd July 2010, 18:47
With 22kHz audio to work with, it's already going to sound a tad bad. Resampling it up to 44kHz isn't going to make it any worse since it's a straight doubling of the samples. VirtualDub's resampling is pretty good; I always check the high quality box. If that's not good enough u can use Advanced Filtering and use its resampling filter to do it. LAME is pretty darn good so I would feel completely comfortable just resampling to 44kHz and using 128kbps CBR. I never go above 192. VDM is my primary tool. HTH.


LA