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."

21 comments

  1. Just flip the bit?! by soegoe · · Score: 1

    If they know the exact bit to twiddle, it shouldn't be too hard to write a program which opens the file, flips the bit, and closes the file again (a one-liner, if you start sufficiently far to the left :-) ). Or am I missing something?

    1. Re:Just flip the bit?! by Saint+Nobody · · Score: 2

      what you're missing is that there's an mpeg header for every mpeg frame in the file. you have to scan to find the first frame (sometimes at the beginning of the file, sometimes after some cruft like id3 tags) then go through, and for each frame, flip the bit, then read the headers to see where the frame ends and the next frame starts.

      --
      #define F(x) int main(){printf(#x,10,#x);}
      F(#define F(x) int main(){printf(#x,10,#x);}%cF(%s))
  2. JEWS MUST DIE OVENS PISS FUCK! by Anonymous Coward · · Score: -1, Troll
    my ovens my ovens. i hate that chysler bought out mercedes. hey made good ovens for me. i will cook jews in them. chrsler will not stain my jew cooking palaces. i will have niggers and jew kapo scrape the human fat off the walls of my jew killing schpizers. i want human ash snow to rain over the towns. i want to see the slashdot editors like the jews in smoke. ashes burning. i want to pull thier kyke teeth out. i want to make doll hair from thier kyke hair. i want to harvest organs from them and throw them in the ovens. i want to make them pregnant and laugh at the sillbonrns. DEATH.

    iiiiiiiiiiiiiiiiiiiiiiiijtiiiiiiiiiiiiiiiiiiiiiiii
    iiiiiiiiiiiiiiiiiiiiiijDMMQtiiiiiiiiiiiiiiiiiiii ii
    iiiiiiiiiiiiiiiiiiiicXMMMMMMQjiiiiiiiiiiiiiiii iiii
    iiiiiiiiiiiiiiiiiicSMMMMMMMMHJiiiiiiiiiiiiii iiiiii
    iiiiiiiiiiiiiiiiiSWMMMMMMMHJiiiiiiiiiiiiii iiiiiiii
    iiiiiiiiiiiiiii6WMMMMMMMNYiiiiiiiiJciiii iiiiiiiiii
    iiiiiiiiiiiii5WMMMMMMMN5iiiiiiiiJHMMSc iiiiiiiiiiii
    iiiiiiiiiii5NMMMMMMMW5iiiiiiiiJHMMMM MWSiiiiiiiiiii
    iiiiiiiiiicXMMMMMMMMNYiiiiiitKMMMM MMMMMW6iiiiiiiii
    iiiiiiiiiiiijDMMMMMMMMHJiitQMMMM MMMMMMMMMW5iiiiiii
    iiiiitciiiiiiijQMMMMMMMMKDMMMM MMMMQWMMMMMMMN5iiiii
    iiitKMWSiiiiiiiijQMMMMMMMMMM MMMMQtiiSWMMMMMMMNYiii
    itQMMMMMW6iiiiiiiitKMMMMMM MMMMKtiiiiicSMMMMMMMMHJi
    iJHMMMMMMMW6iiiiiicSMMMM MMMMMMDjiiiiiiicXMMMMMMN5i
    iiiYNMMMMMMMN5iiiSWMMM MMMMMMMMMMDciiiiiiicDMMW6iii
    iiiii5NMMMMMMMNSWMMM MMMMHNMMMMMMMMXciiiiiiij5iiiii
    iiiiiii5WMMMMMMMMM MMMMN5ii5NMMMMMMMMSciiiiiiiiiiii
    iiiiiiiii6WMMMMM MMMMW5iiiiii6WMMMMMMMWSiiiiiiiiiii
    iiiiiiiiiiiSWM MMMMW6iiiiiiiitKMMMMMMMMXciiiiiiiiii
    iiiiiiiiiiii cSMMWSiiiiiiiitQMMMMMMMMDjiiiiiiiiiiii
    iiiiiiiiii iiiic6ciiiiiiijQMMMMMMMMQjiiiiiiiiiiiiii
    iiiiiiii iiiiiiiiiiiiiijDMMMMMMMMQtiiiiiiiiiiiiiiii
    iiiiii iiiiiiiiiiiiiicXMMMMMMMMKtiiiiiiiiiiiiiiiiii
    iiii iiiiiiiiiiiiiiiijQMMMMMMHJiiiiiiiiiiiiiiiiiiii
    ii iiiiiiiiiiiiiiiiiiiitKMMHJiiiiiiiiiiiiiiiiiiiiii
    iiiiiiiiiiiiiiiiiiiiiiiitYiiiiiiiiiiiiiiiiiiiiii ii
    my ovens my ovens. i hate that chysler bought out mercedes. hey made good ovens for me. i will cook jews in them. chrsler will not stain my jew cooking palaces. i will have niggers and jew kapo scrape the human fat off the walls of my jew killing schpizers. i want human ash snow to rain over the towns. i want to see the slashdot editors like the jews in smoke. ashes burning. i want to pull thier kyke teeth out. i want to make doll hair from thier kyke hair. i want to harvest organs from them and throw them in the ovens. i want to make them pregnant and laugh at the sillbonrns. DEATH.

    JEWS!jews jkyke hymie jew.

  3. Organizing your porn collection? by tps12 · · Score: 0, Flamebait

    Guess there're worse ways to spend a Thursday morning.

    --

    Karma: Good (despite my invention of the Karma: sig)
  4. 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. Re:Use the power of C! by sarabob · · Score: 5, Insightful

      erm... no.

      MPEG headers aren't just at the beginning of the file. You'd have to watch the transport stream for video packets, watch for video headers, and *then* flip the bit. For each one throughout the stream.

      Most available software will want you to strip the transport stream into video/audio elementary streams before doing anything further. You would then work on the video stream and finally remux.

  5. No, it's worse than that by PhysicsGenius · · Score: 0
    His "client" wants to modify the original home bit. That's the bit that indicates the copyright holder of the encoded movie. If the RIAA gets wind of this story on Slashdot, you can bet Slashdot's Attorney will get a cease and desist.

    Thanks for dealing another death blow to Linux's image, Slashdot!

  6. doh by sarabob · · Score: 1

    Hnnng. thought we were dealing with a/v streams, not just audio...

    1. Re:doh by Saint+Nobody · · Score: 2

      it still applies. you'd have to flip the bit in every audio frame header. i looked at doing this sort of thing a while ago, but decided that i didn't have time to do one with all the features i wanted to put in. now that i'm out of school i just might, though.

      --
      #define F(x) int main(){printf(#x,10,#x);}
      F(#define F(x) int main(){printf(#x,10,#x);}%cF(%s))
  7. 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.

    1. Re:I'll help you out by Anonymous Coward · · Score: 0

      Incomplete. The requested information is not there. The complete header description is here.

  8. 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.
    1. Re:dd is your friend, binary editors are for wimps by Anonymous Coward · · Score: 0

      Linus Torvalds, in an article about a dnserver.

  9. You got it by Slashdot's+Attorney · · Score: 1

    Another late night at the office...

  10. 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 !

    1. Re:Well, careful if you release it... by itwerx · · Score: 1, Interesting

      I just read your page - pretty amusing! The last missive from them is dated May 7th though, I'm curious to know what's happened since then...?

    2. Re:Well, careful if you release it... by Anonymous Coward · · Score: 1, Interesting

      Nothing. I think they realized they'd need to take me to court, or else they are actually planning to take me to court and are waiting for the most inconvenient time to do it.

  11. Are you one of those fuckers by Anonymous Coward · · Score: -1, Troll

    That manipulates MPEG headers to display the title as something else then puts the result on Kazaa? I just downloaded what I thought would be Harry Potter and it turned out to be some gay fetish movie called Hairless Peter.

    1. Re:Are you one of those fuckers by madsenj37 · · Score: 1, Troll

      You got what you deserved when you didnt pay for copyrighted work

      --
      Choosing the lesser of two evils is a choice for evil.
  12. problem solved by Anonymous Coward · · Score: 0

    http://www.cmis.csiro.au/maaate/docs/header.txt

    can't believe that useless C snippet got 5, Informative.