Help - Search - Members - Calendar
Full Version: Huge problem with LAME and MP3 in Flash
Hydrogenaudio Forums > Lossy Audio Compression > MP3 > MP3 - General
mluggy
Hi guys,

I just switched to Lame for encoding of hunderds of music files.

I use the following command:
lame.exe -b 64 --cbr --nogap --quiet file1.wav file1.mp3

I then join all mp3 files using
copy /b *.mp3 final.mp3

The file plays great on my Windows Media Player and Winamp, however when I try to stream it through a web flash player, I get fast-forward. see here:
http://www.israel-music.com/efraim_shreibe...rim_shpil_3000/

The original file is here:
http://www.israel-music.com/temp/orig.mp3

Is there any way to fix that? What am I doing wrong?

Thanks!

Michael.
Synthetic Soul
QUOTE(mluggy @ Feb 28 2006, 07:46 PM)
I then join all mp3 files using
copy /b *.mp3 final.mp3
You can't join MP3 files in this way. Each file has a header, so by joining two files together the second file's header will end up part way through the new file. I guess Flash's player can't cope with this. It is bad practice at best.

musiCutter will join MP3 files. Presumably it will do so correctly.
rosshmusic
and you can also use the function in foobar to export mutiple tracks as one file using the converter (I believe diiskwriter can do this as well...

load the wav files and then select all of them (in the order you want them in) and use the converter to export as a single file (using any encoder you want - for you it would just mean making a custom mp3 command line entry)....

I do this all the time with mis-tracked live shows... I can't imagine it wouldn't work for your application... they sound (well, like the chipmunks) like sample clips from the CD, in which case this would work fine....
Synthetic Soul
Sorry, yes; if you have the WAV files then the best option is to concatenate these, and then encode the large WAV to MP3.

For some reason I'd got it into my head that you only had MP3 as source.

Thanks rosshmusic.
mluggy
Do you think there's any way I can rescue the hunderds of files done this way? re-encoding with the basic LAME params didn't help :-(
[JAZ]
QUOTE(Synthetic Soul @ Feb 28 2006, 09:06 PM)
You can't join MP3 files in this way.  Each file has a header, so by joining two files together the second file's header will end up part way through the new file.

*



MP3 does not have a "main" header, at least if we talk about CBR files, which is the case. Sure we could argue that the first frame has the LAME header, but that is skipped by a decoder.


The problem is not in the way it is joined. I *think* that the reason could be that the mp3 is mono, and flash assumes it is stereo.
If the reason is really this one, you can't fix it, except if there is an option in flash to change the number of channels.

Edit: It could be the samplerate too, but i thought flash supported them.
Synthetic Soul
QUOTE([JAZ] @ Feb 28 2006, 10:45 PM)
QUOTE(Synthetic Soul @ Feb 28 2006, 09:06 PM)
You can't join MP3 files in this way.  Each file has a header, so by joining two files together the second file's header will end up part way through the new file.
MP3 does not have a "main" header, at least if we talk about CBR files, which is the case. Sure we could argue that the first frame has the LAME header, but that is skipped by a decoder.

The problem is not in the way it is joined. I *think* that the reason could be that the mp3 is mono, and flash assumes it is stereo.
I just concatenated some MP3s using this method. I then loaded the new file into foobar 0.9, and the reported track length is that of the first track.

This doesn't sound successful to me.

That said, I don't seem to have faired too well in this thread so far, so I probably should have just got out while the going was (midly) good. unsure.gif
Synthetic Soul
OK, I've just tried this again, with the same results. However, Gabriel posted this in another thread:

QUOTE(Gabriel @ Mar 1 2006, 03:12 PM)
QUOTE
Also the following (Copy /b *.mp3 combined.mp3) creates invalid format.
This command should produce valid streams, provided that you respect the following:
*same number of channels
*same sampling freq
*no id3/ape/whatever tag

So, is this a bug in foobar? Mr QuestionMan "correctly" reports the file to be 43:47. foobar 0.9 reports it as 2:31. If I play it only the first song plays (i.e.: it plays for 2:31 also).

foobar 0.8.3 also reports the file as 2:31.

MQM report can be viewed here.

I don't like spreading mistruths, so I would like to see a satisfactory conclusion to this. I'm probably doing something really dumb.
Synthetic Soul
I've just tested this using -t to stop LAME.EXE writing the LAME tag, and foobar now reports the correct length.

Opinions?
senab
QUOTE(Synthetic Soul @ Mar 1 2006, 04:31 PM)
I've just tested this using -t to stop LAME.EXE writing the LAME tag, and foobar now reports the correct length.

Opinions?
*



Well it looks like Foobar is relying on the LAME tag a little too much. Maybe it's something to post in the Foobar Bug forum?

What version of Foobar was you using btw?
Gabriel
By default Lame includes a TOC into the first frame ancillary data. This data is skipped by decoders that do not know how to handle it.
Concatenation of mp3 files produces a correct mp3 stream, compliant with the standard.
However, it might happen that some players that know about the additionnal TOC will see the initial TOC, which is the TOC of the first file, and trust it to be the correct TOC for the new file.
You can not really blame players for such behavior.
Anyway, this does not impact compliance of the resulting mp3 stream.
Synthetic Soul
Thanks for the technical info Gabriel.

It's not much use being compliant if I can only play the first track of an album in foobar, or other players that rely on the TOC, though.

I just went to the URL quoted in the first post. Firstly, the result is hilarious. Secondly, could this double-time be caused by the fact that the data and initial TOC don't match?

Rather than me try to dig myself out of my hole I thought I could divert attention back on to the original question: why does the Flash player have trouble with these files?

While you ponder that I'm ducking back under the stone I crawled out from...

QUOTE([JAZ] @ Feb 28 2006, 10:45 PM)
I *think* that the reason could be that the mp3 is mono, and flash assumes it is stereo.
If the reason is really this one, you can't fix it, except if there is an option in flash to change the number of channels.

Edit: It could be the samplerate too, but i thought flash supported them.
This could be easily tested by simply using a non-concatenated file couldn't it?

mluggy, do you get the same issue using one of the original files (before you merge it using COPY)?
Shade[ST]
Would using foobar2000's "fix entire stream" in "fix mp3 header" feature work to fix this problem?
Synthetic Soul
I tried a couple of settings, a few of which included rewriting the whole stream, and it didn't work.

That's not to say it definately won't; I'm not that up on this tool. Nothing I tried worked though.
xmixahlx
wouldn't you pipe the multiple wav inputs into lame? like:

sox *wav -t wav - | lame - filename.mp3

joining afterwards seems weird to me, but whatever...


later
mluggy
QUOTE(xmixahlx @ Mar 1 2006, 02:01 PM)
wouldn't you pipe the multiple wav inputs into lame? like:

sox *wav -t wav - | lame - filename.mp3

joining afterwards seems weird to me, but whatever...


later
*



That worked great when trying new files - Thank you so much! and thank you Synthetic soul for the effort. I had followed your recommendations (using -t, fixing streams, etc.) but apparently I needed a real tool (like SOX) to join the files together.

Now if I could only fix these old problematic files.. :-(
Synthetic Soul
QUOTE(mluggy @ Mar 1 2006, 09:28 PM)
thank you Synthetic soul for the effort. I had followed your recommendations (using -t, fixing streams, etc.) but apparently I needed a real tool (like SOX) to join the files together.
See posts 3 and 4. It was suggested back then that you join the WAVE files, if you had them, and then convert to MP3.

QUOTE(mluggy @ Mar 1 2006, 09:28 PM)
Now if I could only fix these old problematic files.. :-(
See posts 5 to 14. We are trying to work out where the process has fallen down. Are you able to answer my question in post 12 please?

With regard to the files that you have already merged: do you have the original WAVE files? If not, do you have the MP3 files before they were joined (i.e.: if "a.mp3" and "b.mp3" are joined to make "c.mp3" do you still have "a.mp3" and "b.mp3", so that perhaps you can make "d.mp3")?

If you still have the source WAVE files then you could use SOX in a batch file to do all joins in one run.

If you don't have the source WAVE files but have the source MP3 files, depending on your answer to my question, we may be able to help you batch join these also.

Either way I'd really appreciate an answer to my question. This thread contains information that may be useful to other members who want to join MP3s and/or want to use MP3 with Flash. If we can tie up all the loose ends it may help other members with the same problems. Thanks.
mluggy
QUOTE(Synthetic Soul @ Mar 2 2006, 02:55 AM)
See posts 3 and 4.  It was suggested back then that you join the WAVE files, if you had them, and then convert to MP3.

I had the original WAV files of only 1 CD so I tried that. Concating the WAV first using copy /b didn't work in flash. Using FooBar's Convert into a single file worked well, but I couldn't see how this can be automated, so I let it go.

QUOTE(Synthetic Soul @ Mar 2 2006, 02:55 AM)
See posts 5 to 14.  We are trying to work out where the process has fallen down.  Are you able to answer my question in post 12 please?

I tried encoding the merged file in Mono and fixing the stream using Foobar's FIX options - it didn't work in Flash. I didn't test a single (non-concated) track as it appear a useless test.

QUOTE(Synthetic Soul @ Mar 2 2006, 02:55 AM)
With regard to the files that you have already merged: do you have the original WAVE files?  If not, do you have the MP3 files before they were joined (i.e.: if "a.mp3" and "b.mp3" are joined to make "c.mp3" do you still have "a.mp3" and "b.mp3", so that perhaps you can make "d.mp3")?

If you still have the source WAVE files then you could use SOX in a batch file to do all joins in one run.

If you don't have the source WAVE files but have the source MP3 files, depending on your answer to my question, we may be able to help you batch join these also.

Either way I'd really appreciate an answer to my question.  This thread contains information that may be useful to other members who want to join MP3s and/or want to use MP3 with Flash.  If we can tie up all the loose ends it may help other members with the same problems.  Thanks.
*



Since I don't have the original WAV files I can't use the new SOX batch (which works great). I do have the MP3 files and i'll appriciate any idea on how to fix those (uptill now i've tried re-encoding with various LAME switches and bitrates).

Here's the process I use with SOX, simply create this as a batch file:

CODE

@echo off
set /p varname="Enter MP3 filename to export (i.e - final.mp3)"
C:
cd\
cd PATH_TO_WAV_FILES
C:\PATH_TO_SOX\sox *.wav -t wav chunk.wav
C:\PATH_TO_LAME\lame.exe -b 64 --cbr -m m --quiet chunk.wav C:\PATH_TO_EXPORT\%varname%
del *.wav

For some reason concating everything on the same line didn't work as well, so I had to manually browse the WAV directory and perform the process in 2 phases.

Thanks again!
Synthetic Soul
QUOTE(mluggy @ Mar 2 2006, 10:00 AM)
I didn't test a single (non-concated) track as it appear a useless test.
[JAZ] suggested that it is purely the fact that the file is mono and/or has the wrong samplerate, and not the concatenation process that was causing the problem in Flash.

If you test a file that hasn't been concatenated, or tell me that you know this (not) to be the case, you can prove or disprove this. We then know where to keep looking.

I promise I am not asking you to do things for my own amusement. blink.gif
mluggy
Jaz might've been right! I did numerous other tests and the final mp3 worked correctly ONLY when encoding as mono (i.e - adding "-m m" switch to LAME).

I tried re-encoding the old files with "-m m" and it didn't work, however. I guess they were ruined.
Synthetic Soul
QUOTE([JAZ] @ Feb 28 2006, 10:45 PM)
I *think* that the reason could be that the mp3 is mono, and flash assumes it is stereo.
If the reason is really this one, you can't fix it, except if there is an option in flash to change the number of channels.

Edit: It could be the samplerate too, but i thought flash supported them.
QUOTE(mluggy @ Mar 2 2006, 04:00 PM)
Jaz might've been right! I did numerous other tests and the final mp3 worked correctly ONLY when encoding as mono (i.e - adding "-m m" switch to LAME).

I tried re-encoding the old files with "-m m" and it didn't work, however. I guess they were ruined.
I think I give up. I'm getting an ulcer.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.