Log in

View Full Version : Adding information to MPEG file


Dan203
20th February 2006, 20:09
I'm looking for is some way to add metadata to regular .mpg file so that my own software can read it and display/use it, while other MPEG players will simply ignore it and play the audio and video. I've done some searching and found some news group postings that suggest you can add any kind of data you want to an MPEG stream using "user data" or "private streams". However I can't find any real useful information on how exactly to do it.

So I guess my first question is... Is this even possible? And if so could someone point me at some documentation and/or code samples to show how it's done?

Thanks,
Dan

Squee0
22nd January 2007, 01:04
I also would be interested in a program to add/change the metadata/User Data of MPEG-2 Files

Guest
22nd January 2007, 01:30
Everything you need to know is in the MPEG2 video specification document:

http://neuron2.net/library/mpeg2/iso13818-2.pdf

Look for extension_and_user_data(). You can have it at any of these levels: sequence, gop, or picture. The start code is 00 00 01 b2. You just insert your start code and data at the right place in the stream, as defined in the referenced specification. You'll have to parse the sequence header and extension to find the right place, of course (assuming you use the sequence level user data).

mpucoder
22nd January 2007, 15:11
One warning, though, make sure to avoid appearing as a DVD use of the user data. Specifically the GOP user data beginning with 0x43 0x43, this is closed captioning.

Squee0
22nd January 2007, 15:46
This PDF (as far as I noticed) doesn't talk about how to insert UserData/Matadata after the file has already been created, and a HEX Editor won't work cause the files are too large, the Hex Editor can't handle them, already tried. So far I've only found one program that would possibly work but it requires the video to be demultiplexed from the audio first, so that's a real pain in the ass demultiplexing and then remultiplexing them back together...

Everything you need to know is in the MPEG2 video specification document:

http://neuron2.net/library/mpeg2/iso13818-2.pdf

Look for extension_and_user_data(). You can have it at any of these levels: sequence, gop, or picture. The start code is 00 00 01 b2. You just insert your start code and data at the right place in the stream, as defined in the referenced specification. You'll have to parse the sequence header and extension to find the right place, of course (assuming you use the sequence level user data).

kumi
22nd January 2007, 15:53
Hi Squeeo,

Give Restream a shot, it allows you to add User Data to MPEG2 elementary streams.

http://img228.imageshack.us/img228/2272/restream5rq.jpg

Guest
22nd January 2007, 15:58
This PDF (as far as I noticed) doesn't talk about how to insert UserData/Matadata after the file has already been created, and a HEX Editor won't work cause the files are too large, the Hex Editor can't handle them, already tried. That's a poor editor. Get a decent one.

So far I've only found one program that would possibly work but it requires the video to be demultiplexed from the audio first, so that's a real pain in the ass demultiplexing and then remultiplexing them back together... If the stream is a program stream your job is a bit harder but you can still do it without demuxing/remuxing. You'll likely have to write your own tool for this. The specs for program streams are in the System specification, also available at my site.