FFmpeg: How can I convert a stream of mp3 bytes to a properly-formatted ogg file?
-
I'm using mplayer to dump a m3u stream into an mp3 file, but if I pick up in the middle of the event it doesn't catch the header info on the streamed mp3 file so I just end up with a collection of mp3-formatted bytes. This pseudo-mp3 file plays fine in VLC and Chrome (via <audio>). However, I also need to support Firefox, so I tried converting the file to ogg using ffmpeg; this works, but ffmpeg complains about not finding a header on the mp3 file and in the end Firefox refuses to play the ogg file because it's 'corrupted' (it plays in VLC but without showing a max duration). Any thoughts? (I'm on Arch Linux if it matters.)
-
Answer:
MP3 (per se) doesn't have a header. The MPEG-1 and MPEG-2 video and audio formats were designed to be broadcast to many receivers who might tune in to the channel at any point. As long as you cut on a frame boundary (which you should do!) the result is valid MPEG-1/MPEG-2 audio. If you cut in the middle of a frame, the result will be valid MPEG-1/MPEG-2 audio with a small amount of junk at the beginning before the first synchronization word, which many decoders will still handle fine. But not all. (There are some dubious additions to MP3 designed by warez traders in the mid-1990s, like ID3, that are "file-based" and only come at the beginning. These are not part of the ISO MPEG standards. And Ogg Vorbis is different. Vorbis files usually do contain a header at the beginning of the file that is important to the decoding process.) Cutting MP3 streams on a frame boundary is one way to do it, but this may not be so easy. (In MP3 these generally start with 0xff 0xfa, but not always, and their length can vary if the file was encoded with a variable bitrate.) The easier approach is probably to convert your "cropped" MP3 to a WAV file, and play it back to make sure it sounds good. Then convert the WAV to Ogg Vorbis using the method of your choice.
Keith Winstein at Quora Visit the source
Related Q & A:
- How can I convert a string number to a number in Perl?Best solution by Stack Overflow
- How can I convert real player audio files into mp3?Best solution by Yahoo! Answers
- How can I convert a video to mp3 format?Best solution by Yahoo! Answers
- How can I get a job at a resort for a Summer?Best solution by eHow old
- How can i convert a game on my old pc to my new pc?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.