Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Huge problem with LAME and MP3 in Flash (Read 8774 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Huge problem with LAME and MP3 in Flash

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.

Huge problem with LAME and MP3 in Flash

Reply #1
Quote
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.
I'm on a horse.

Huge problem with LAME and MP3 in Flash

Reply #2
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....

Huge problem with LAME and MP3 in Flash

Reply #3
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.
I'm on a horse.

Huge problem with LAME and MP3 in Flash

Reply #4
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 :-(

Huge problem with LAME and MP3 in Flash

Reply #5
Quote
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.

[a href="index.php?act=findpost&pid=368093"][{POST_SNAPBACK}][/a]


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.

Huge problem with LAME and MP3 in Flash

Reply #6
Quote
Quote
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. 
I'm on a horse.

Huge problem with LAME and MP3 in Flash

Reply #7
OK, I've just tried this again, with the same results.  However, Gabriel posted this in another thread:

Quote
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.
I'm on a horse.

Huge problem with LAME and MP3 in Flash

Reply #8
I've just tested this using -t to stop LAME.EXE writing the LAME tag, and foobar now reports the correct length.

Opinions?
I'm on a horse.

Huge problem with LAME and MP3 in Flash

Reply #9
Quote
I've just tested this using -t to stop LAME.EXE writing the LAME tag, and foobar now reports the correct length.

Opinions?
[a href="index.php?act=findpost&pid=368318"][{POST_SNAPBACK}][/a]


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?

Huge problem with LAME and MP3 in Flash

Reply #10
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.

Huge problem with LAME and MP3 in Flash

Reply #11
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
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)?
I'm on a horse.

Huge problem with LAME and MP3 in Flash

Reply #12
Would using foobar2000's "fix entire stream" in "fix mp3 header" feature work to fix this problem?

Huge problem with LAME and MP3 in Flash

Reply #13
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.
I'm on a horse.

Huge problem with LAME and MP3 in Flash

Reply #14
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

Huge problem with LAME and MP3 in Flash

Reply #15
Quote
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
[a href="index.php?act=findpost&pid=368379"][{POST_SNAPBACK}][/a]


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.. :-(

Huge problem with LAME and MP3 in Flash

Reply #16
Quote
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
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.
I'm on a horse.

Huge problem with LAME and MP3 in Flash

Reply #17
Quote
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
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
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.
[a href="index.php?act=findpost&pid=368492"][{POST_SNAPBACK}][/a]


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: [Select]
@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!

Huge problem with LAME and MP3 in Flash

Reply #18
Quote
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. 
I'm on a horse.

Huge problem with LAME and MP3 in Flash

Reply #19
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.

Huge problem with LAME and MP3 in Flash

Reply #20
Quote
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
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.
I'm on a horse.