Re: I dream of converting this file to a real mp3
"Kelly Jones" <[email protected]> Tue, 28 Oct 2008 17:33:12 -0700
| Newsgroups | gmane.org.user-groups.nmlug |
|---|---|
| Message-ID | <[email protected]> |
Is the sync word always 4 'ff' (decimal 255) in a row? % \od -x jeannie1.wav | fgrep ffff 0000440 9d09 364d ffff e8ff 6a32 3067 ed65 bf4d 0000460 ffff faff ca0c 0634 d830 3064 3f03 f8ff 0002500 0e18 ffff 4765 1245 9f36 2cfd 66c5 f627 0012300 4d4a ffff 0876 0e04 9070 81e1 05df ac9e 0014000 4e6b c8cb 4bad 23cb ffff a4cc a4b2 27a7 0047360 ffff 3345 8e15 3f1d 76f4 6cce 28f4 f568 0076620 ffff c0fd 56d5 002b 1808 ea5b 2beb 0f4b 0100040 0735 89b4 1626 4bf9 ffff 97fd f470 cea5 0100440 524b 86dc f9a6 a7dc ffff 1df9 a5f7 74b4 0101460 ffff e5fe 2e72 42a4 d3a3 3d65 ff7f f992 0267440 e0e2 ffff e0fc ae45 40c5 754d ca35 434f 0342540 1288 b188 4799 ffff 8afc 5391 0422 d239 (for the cases where the line starts with 'ffff', I did check the previous row-- no 'ffff' or simliar at the end). There are some 'ffff ffff' at the end of the file, but I can't imagine the MP3 starts that late. Can the sync word be 'ffff xxff' where xx can be anything? The first part of the file is indeed the RIFF/WAVE header: % \od -c jeannie1.wav | head 0000000 R I F F > 307 001 \0 W A V E f m t 0000020 036 \0 \0 \0 U \0 001 \0 021 + \0 \0 304 \t \0 \0 0000040 001 \0 \0 \0 \f \0 001 \0 002 \0 \0 \0 004 001 002 \0 0000060 q 005 f a c t 004 \0 \0 \0 334 325 \a \0 d a 0000100 t a \0 307 001 \0 377 343 0 304 \0 031 001 Q 255 231 0000120 L x 002 Y U 276 J \0 216 254 340 @ & : \t 205 0000140 c 300 023 - 217 \0 @ ( Z 023 201 367 204 2 332 A 0000160 230 311 , 237 031 316 253 l C 025 022 220 r 026 304 0000200 = h 363 p z \f 206 322 016 8 334 216 u Z 220 [ 0000220 \v 002 370 267 213 232 331 316 253 ` C 031 033 316 s 256 -- We're just a Bunch Of Regular Guys, a collective group that's trying to understand and assimilate technology. We feel that resistance to new ideas and technology is unwise and ultimately futile. On 10/28/08, Wesley J. Landaker <[email protected]> wrote: > On Saturday 25 October 2008 22:04:48 Kelly Jones wrote: >> I have an odd file: >> > file jeannie1.wav >> >> jeannie1.wav: RIFF (little-endian) data, WAVE audio, MPEG Layer 3, >> mono 11025 Hz > [...] >> What's the correct way to convert jeannie1.wav to MP3 with a single >> lame command, short of folding my arms and blinking? > > The problem that you are having -- and most answers seem to be missing the > point of -- is that your file already is essentially an MP3, but > it's "disguised" as a WAV file and isn't in the usual MP3 format file. > > What we call ".wav" files are actually general RIFF containers that happen > to only have WAVE audio chunks. Usually when you get your hands on a ".wav" > file, it has PCM audio data, but that's not required. WAVE audio actually > supports all sorts of codecs like GSM, or in your case, MPEG-1 Audio Layer > 3 (i.e. MP3). > > What we call ".mp3" files are either raw MP3 frames or MP3 frames > encapsulated in the ID3 container format. > > So if you are using lame anywhere in the chain, that's not very optimal: it > means you have decoded and are now re-encoding the data and will suffering > a corresponding quality loss. What you really want is change container > formats while keeping the data static. > > It's actually pretty easy to convert in this situation. Here are a couple > ways: > > 1) Rename ".wav" to ".mp3" -- since MP3 self-synchronizes upon playback, > the RIFF header will just look like garbage and will be skipped until the > actual MP3 data is found and played. The garbage is there, so this > is "wrong", but in practice this will probably work with any player. > > Example: > cp jeannie1.wav jeannie1.mp3 > > 2) Rename, then strip the RIFF header off with a hex editor. This is > actually pretty trivial if you know what you are doing, and will avoid > garbage at the front of the MP3 file. This is good if it's giving you > trouble, or you just want to do it "right". > > Example: > cp jeannie1.wav jeannie1.mp3 > khexedit jeannie1.mp3 > (strip RIFF header by e.g. looking for first MP3 sync word ff ff ff ff) > > 3) If your sox is compiled with MP3 support, it can convert container > formats without touching the data. Unfortunately, sox does not support MP3 > by default in most distributions. > > Example: > sox jeannie1.wav jeannie1.mp3 > > 4) Write (or find) a simple program that will simply strip the RIFF header > like #2. This would probably be about 5-10 lines of python, for example. > > -- > Wesley J. Landaker <[email protected]> <xmpp:[email protected]> > OpenPGP FP: 4135 2A3B 4726 ACC5 9094 0097 F0A9 8A4C 4CD6 E3D2 _______________________________________________ NMLUG mailing list [email protected] http://lists.b9.com/cgi-bin/mailman/listinfo/nmlug