View Full Version : Finding I-Frames in MPEG-2 PS or TS
ruby33
6th October 2009, 06:45
Hi guys,
I am trying to find out a way to detect I-Frames in a Mpeg2-PS or TS stream.
I tried it with Mpeg2-PS, as in started looking for the occurrence of the byte sequence "00 00 01 00" for all MPEG-2 PS Packs having a PTS or PTS and DTS with stream type E0 (Video Stream). With this, atleast the I-Frame,P-Frame and B-Frame count matched with that of VirtualDubMod 1.5... Please let me know if this is a correct approach or not.
Thanks,
Ruby
Guest
6th October 2009, 14:25
It's too stringent as it is not required that all frames carry PTS/DTS (they can be interpolated), and there are other video stream ids than E0.
ruby33
7th October 2009, 06:44
Hi neuron2 thanks soo much for the reply.
Then how is it that i can figure out which Streams contains frames? Is there some documents on the same.
So far the samples which i have contains only EO video frames. Verifying the same with wireshark. If you can point me to the right direction it will be of great help
Thanks,
Ruby
ruby33
7th October 2009, 09:28
Hi Neuron , there is a small question which i want to ask.
In wireshark, they say the first Pack always contains the quantization matrix and my first I-Frame is always contained in that. Again i am a noob. If you could take sometime in explaining or point me to a document which does describe everything it will be of great help. Please
Ruby
Guest
7th October 2009, 13:53
Refer to the MPEG2 spec for details on stream IDs. You just need to check for the possible legal stream IDs. Almost always it is 0xe0 but I have seen other cases.
I don't know what wireshark is but what you've quoted is not necessarily true.
Just parse for 00 00 01 00 in your elementary video stream and for field pictures count half a frame and for frame pictures count a full frame. Don't make the job harder than it is.
ruby33
7th October 2009, 15:56
Thanks a lot neuron , i will complete this work and get back to you.. thanks again.
kreet
7th October 2009, 15:59
neuron2: wireshark is the new ethereal.
ruby33: I,P and B -frames are elements in MPEG compression, not the MPEG 2 Transport/Program Stream spec. you cant really rely on PTS/DTS field for information about frames. you need to move up a layer to the elementary stream itself. most streams mark frames clearly in their packets.
you should look at the mpeg2 compression specs or mpeg4 if you are inspecting a mpeg4 encoded video transmitted over mp2ts.
ruby33
7th October 2009, 16:24
Hi kreet,I have to learn MPEG-2 and will currently be in studying the same. my idea is to first learn about the PES structure as in able to differentiate between the I,B,P Frames . In order to do that i have started digging into Mpeg2 PS. After i am able to do that i will start working on Mpeg2-TS. With the Mpeg2-ts i have to handle the adaptation field also. I figured it will be easier this way. Ultimately i have to learn MPEG-2 Codec . Thanks for the help
-Ruby
kreet
7th October 2009, 19:19
m2ts is the 'Systems' portion of mpeg-2 and covers both PS and TS. they are very similar. I,B,P frames are not covered by this standard at all, you need the 'Video' section 2 (13818-2).
for more on Systems see http://en.wikipedia.org/wiki/MPEG_transport_stream and the standard itself: ISO 13818-1
for more on Video see http://en.wikipedia.org/wiki/Mpeg2, http://en.wikipedia.org/wiki/Video_compression and the standard ISO 13818-2
you should really read and understand the standards first before trying to implement things ;)
eslave
24th October 2009, 01:55
MPEG Video stream values are 0xE0 through 0xEF, but scanning for Picture codes alone would certainly be easier.
The last time I dared to tinker with this stuff I made extensive use of these two pages:
http://dvd.sourceforge.net/dvdinfo/mpeghdrs.html
http://dvd.sourceforge.net/dvdinfo/pes-hdr.html
Though slightly lacking in some details I found it much easier to digest than the ISO docs. :)
Learn to use your programming language's bit-shift operations to place the LSB where it belongs, and then use the bit-wise AND operator to mask-off any remaining unwanted bits. Knowing how to merge bytes into words or doublewords and using 64-bit data-types for playing with 33-bit (how handy!) timestamps can also prove useful.
-eslave
ruby33
30th October 2009, 13:48
Hi Eslave and kreet,
Thanks a lot to both of you. kreet i couldn't get my hands on the Video Doc 13818-2 and eslave.. Yes i had to depend a lot on the webpage u made it was really helpful.
Now i will be doing research on how to Joining video clips without getting artifacts. When i just tried joining video clips from two different source , i ended up getting artifacts and the error i think was because of the mismatch of Presentation Time Stamps. Anyways thanks again.
Cheers,
Ruby
Guest
31st October 2009, 00:42
i couldn't get my hands on the Video Doc 13818-2 Did you try here:
http://neuron2.net/library/mpeg2/iso13818-2.pdf
ruby33
2nd November 2009, 06:18
Thanks neuron
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.