Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appending the recorded MP3 ecoded Data to an existing MP3 file. #1

Open
JalalSordo opened this issue Sep 12, 2015 · 1 comment
Open

Comments

@JalalSordo
Copy link

I set the encoder to 16kbps as biterate using "direct" encoding i get a blob, i can append the latter to a new recorded one and get a new blob that has the duration of the two blobs and iit is playable by chrome.

The problem is when i load a mono 16kbps lame encoded mp3 file from the db and try to append to it the newly recorded track with Mp3LameEcoder.js,
The resulting file has correct duration, but unfortunately not playable, although i play it withe vlc player:
It is playable but when hits the start of the appended blob the current time monitor on vlc player gets messed up.

I used a Java program to compare the different files i got the following:
My db Blob : 16kb,11025 sample rate, Mono.
Recordings of Mp3LameRecorder.js: 16Kb,41100 sample rate, Joint Stereo.

I changed the channels section in Mp3LameRecorder.js to encode one channel but no avail, it's the same result.

function _lame_set_num_channels($gfp,$num_channels) : $num_channels = 1;

After some mp3 file analysis i think you encode with MPEG-2 Layer III while my db mp3's are MPEG-2.5 Layer III which encoded with 16kbps.

@higuma
Copy link
Owner

higuma commented Sep 13, 2015

Hi,

First of all, I don't know about tools you are using (what's db?, vic player? and so on ... I only know foobar200, Audacity and other few tools). I can't help you about these things.

I don't think it is OK to append encoded data to another existing MP3. All MP3 file has a header block. Data chunk after header relies on header information. Concatenating two different data obviously fails.

Also, I did not intend such VERY low (16k!) bitrate. I imagine you want to record some low quality voice memo or so on. But LAME has been mostly designed for hi-fi audio.

(I think) this is why it is difficult to set MONO mode for LAME. LAME API needs special setup for mono encoding (not enough with setting num_channels to 1). API spec deeply depends on multi-channel hi-fi data.

In fact, I don't know about exact API setup for encoding mono data. Even lame.exe (or other binary command for each environment) needs special options to set mono. But I dont know how to set it from API.

You can search for forks of akrennmair/libmp3lame-js and their variations on google. Some of them are trying to set mono (as you want).

But I would rather recommend Ogg Vorbis. Vorbis support mono channel easier and has better performance for low bitrate. I have made JavaScript Vorbis encoder with similar interface as Mp3LameEncoder.js. See below.

https://github.com/higuma/ogg-vorbis-encoder-js

LAME has some copyright issues. Obvoiusly you cannot use it for a commercial purpose. Furthermore, MP3 has gap problems but Vorbis is gap-free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants