Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Music Media

Splitting Mp3's 16

caseydk writes: "I'm working on a project that needs to take a single mp3 (a live recording) and play individual sections of it. Preferably, so that the user must only download a portion of the mp3, instead of the whole thing. Unfortunately, most (or all) mp3 splitters that I have found have a gui. I'm looking for something command-line, so that I can just have the server do it during low usage times or (worst case) on the fly. Any suggestions?"
This discussion has been archived. No new comments can be posted.

Splitting Mp3's

Comments Filter:
  • mpg toolbox (Score:3, Informative)

    by LinuxGeek8 ( 184023 ) on Friday August 03, 2001 @09:53AM (#2133147) Homepage
    You should check out mpgtx, the mpg toolbox.
    It's heading for a stable 1.0 release.
    You can find it on http://mpgtx.sourceforge.net [sourceforge.net]

    By the way, splitters with a gui?
    I find it hard to find a mpg splitter with a gui.
    I do know mpgcut (or mpcut?) and bc2000.
    Which ones are you referring to?
    • there's a windows program called "mp3 butcher" that is full-on gui oriented; works well, it's free. i use it over Samba to slice up 75meg live recordings to fit on my Rio....

      -te
  • headerless format (Score:4, Informative)

    by Rebar ( 110559 ) on Friday August 03, 2001 @08:59AM (#2147496)
    Since MP3 is headerless, you should be able to just calculate where in the file you want to be based on the bitrate, and use 'dd' to cut out a snippet.

    I've tried this and it sometimes works and sometimes doesn't depending on the player, since the start of your file snippet will have junk in it, but it seems to me that it would be an easy programming exercise to create a program that would lop off the leading junk until it finds the next valid MP3 frame.

    I don't claim to know much about MP3 format, but it appears from a quick session with a hex editor that frames start with 0xfffb9200 - can anyone verify this? If so, you could hack out something in an hour that would be fast, scriptable and do exactly what you want.

    For extra credit points, you could then use mp3info to add id3 tags so your file will look cool when playing in xmms or whatever.

    • Re:headerless format (Score:3, Informative)

      by Anonymous Coward
      A quick google search on "mp3 header" [google.com] found this document [mirc-egg.net] on the mp3 header format. Where I learnt that the beginning of each frame starts with the first 11 bits set to 1, so you can use this to write a quick script to split a mp3 up into pieces.
      • by Anonymous Coward
        MP3 has a "bit reservoir", meaning that MP3 frames are NOT independent of each other. Splitting it using only the headers (without understanding the MP3 data stream) may cause artifacts at the beginning or end of a clip. Most likely, you'll hear annoying static/pops at the beginning of the clip (often they're really loud, and may even damage speakers if the volume is up too loud).

        If you're encoding MP3 files and intend to split them like this, try to disable the bit reservoir. If you use LAME, the --nores switch will disable it. This may degrade quality slightly, but if you're using VBR or ABR mode it won't really matter. Instead of "lame -b 128", use "lame --nores --abr 128" for example. Then you can split the MP3 without problems.

    • Well, except for the first 16(?) bytes, and if its not a variable bitrate mp3, its headerless. Its been a long time since I've looked at the file structure, and back in the day (WinPlay3 was the only real player...) Fraunhoffer wasn't too keen on releasing any specs. Oh well, Riff6 still works...
  • I've done this... (Score:5, Informative)

    by Brazilian Geek ( 25299 ) on Friday August 03, 2001 @09:26AM (#2147708) Journal
    ... using dd.

    I know about the MP3 file header but before I knew about it I was chopping MP3s just for kicks. It works, it's easy and knowing the kbps of the file you can calculate the exact point to start and end. Example:

    dd if=biggie_file.mp3 of=shortie_file.mp3 bs=1c seek=200k count=150k

    It REALLY does work and it's command line - not to mention all the piping possibilites.
    • This does not always work. If everyone used great MP3 players like we do, this would be fine, but many are screwed up by leading garbage on the file.

      For downloads where you don't know what will be playing your file, I'm afraid that you must clean up the front of the file first.

      It is realy easy to make mpg123 report: Illegal Audio-MPEG-Header 0x3818402e at offset 0x367. or something similar and play very annoying screeches after using dd to chop mp3 files.

      • I get a lot of those but after studdering a bit at the begining of the chopped file but after a few seconds it plays smoothly.

        I chopped an episode of the HHGttG a few weeks ago - I wanted to put the 'Share and Enjoy' song onto my MP3 player - and after locating the spot it started and for how long it played I dd'd it and presto - I passed it through mpg123 and it worked.

        I guess it's just a matter of luck finding the correct spot to grab a header.
      • No, not to beat a dead horse, but if you do this you will get .mp3 files that simply will not play with some highly respected players. Try it yourself:

        for i in 0 1 2 3 4 5 6 7 8 9; do
        for j in 0 1 2 3 4 5 6 7 8 9; do
        dd if=yourfav.mp3 skip=1${i}0${j}00 bs=1 count=30000 of=test${i}${j}.mp3
        done
        done
        for i in test*mp3; do mpg123 $i; done

        I get 30 that mpg123 won't touch at all (returns failure code), and a few more that it attempts but makes a gawdawful screech. Xmms will play them all. Go figure.

        Point is, I would not stand for that sort of failure rate from a web site I was in charge of, especially if I have no control over the player involved. Would you?

  • by Animol ( 120579 ) <jartis&gmail,com> on Friday August 03, 2001 @09:35PM (#2160810) Journal
    Well, you could always just set up a Lego Mindstorms robot to open your case, remove a platter from a hard drive (assuming that's where they're stored) and physically operate a bandsaw to trim the media. There's no good way to reunite it but it's effective. If the songs are on a CD, just increase the laser's power to section off the track in question. I find physical separation of data makes for much better organization, if less practical use.

THEGODDESSOFTHENETHASTWISTINGFINGERSANDHERVOICEISLIKEAJAVELININTHENIGHTDUDE

Working...