Slashdot Mirror


Tools for Manipulating MPEG Headers?

mattjarvis asks: "Does anyone out there know of a software solution for batch manipulating MPEG file headers, ie. stripping the header and replacing it with another header, or editing the existing header. I've searched the usual places, and have come up with a few libraries that look like they are capable of doing this but I don't seem to be able to find anything already written to do this. Basically I have a client using a hardware MPEG audio recorder, who wishes to change one of the bits in the header ( the original/home bit ) which is causing some problems with other software they are using. Surely this should be relatively simple to achieve and it's possible that I am missing the obvious but there doesn't seem to be anything available open source or not to easily edit the header without reconverting the actual audio stream."

5 of 21 comments (clear)

  1. Use the power of C! by theCoder · · Score: 4, Informative
    You just want to do a simple operation on a whole bunch of files. Normally, you'd probably want a shell script, but since what you're doing (changing a bit) is fairly low level, you should probably consider a quick C program. I'll even block it out for you:
    int main(int argc, char** argv)
    {
    // for each argument (that's a file)
    {
    // mmap the file
    // flip the bit (you know the offset, right?)
    // sync and un map the file
    }
    printf("Done!\n");
    return 0;
    }
    Now, that wasn't that hard, was it? You don't ALWAYS have to find third party tools to do your job for you.

    --
    "Save the whales, feed the hungry, free the mallocs" -- author unknown
    1. Re:Use the power of C! by Anonymous Coward · · Score: 1, Informative

      The mpeg audio format has a header for each frame. To do it right, you have to step through the file frame by frame and flip the bit in each frame's header. That's a fairly easy operation on a correct standards compliant file, but when you're dealing with corrupted or otherwise incorrect data (unspecified tags in the stream for example), you have to resync the stream, which sounds easier than it is. Simply looking for the $fff sync sequence isn't always the best method.

  2. I'll help you out by Chris+Pimlott · · Score: 5, Informative

    here is all the information you should need. I used it myself when making a mp3-inspecting program.

  3. dd is your friend, binary editors are for wimps by Gothmolly · · Score: 3, Informative

    man dd
    find the bits you're looking for and swap them around, done.

    Bonus Karma for people who know where the subject is quoted from.

    --
    I want to delete my account but Slashdot doesn't allow it.
  4. Well, careful if you release it... by Tom7 · · Score: 5, Informative


    Is this a "copyright" bit? (Like the bit set when you make a digital copy of a minidisc?) If so, be careful if you release this program, or you might run into problems similar to my own bit-flipping software !