Digital Video Forums

Go Back   Digital Video Forums > Other > Archive (Closed) > General Discussions

 
 
LinkBack Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 15 Dec 2008, 08:10 PM   #1
Junior Member
Junior Member
 
Join Date: Dec 2008
Posts: 4
Default Help : Extract I-frames from MPEG2-TS

Hi,

I want to know when an I-frame starts and ends when I analyse an mpeg2-ts stream. I do not have access to the ISO :13818-1.

Can anyone help me please. What fields of the MPEG2-TS streams must I check to know the start and the end of an Inter-Frame ?

Thank you.
sarnov is offline  
Old 15 Dec 2008, 11:29 PM   #2
Not a god of digital video
 
blutach's Avatar
 
Join Date: Oct 2004
Location: is everything!
Posts: 24,628
Default



You need to look at the picture header start code (4 bytes = 0x0100). Skip the next byte and then byte 5 tells you what you want to know. Extract bits 3, 4 and 5 (remember that a byte is bits 0-7).

Values of bits 3, 4 and 5

Code:
001 = I frame
010 = P frame
011 = B frame
It will continue on till it hits the next one (which will probably be a P frame).

More info

Regards
__________________
Les

Essential progs - [PgcEdit] [VobBlanker] [MenuShrink] [IfoEdit] [Muxman] [DVD Remake Pro] [DVD Rebuilder] [BeSweet] [Media Player Classic] [DVDSubEdit] [ImgBurn]

Media and Burning - [Golden Rules of Burning] [Media quality] [Fix your DMA] [Update your Firmware] [What's my Media ID Code?] [How to test your disc]
[What's bitsetting?] [Burn dual layer disks safely] [Why not to burn with Ner0] [Interpret Ner0's burn errors] [Got bad playback?] [Burner/Media compatibility]

Cool Techniques - [2COOL's guides] [Clean your DVD] [Join a flipper] [Split into 2 DVDs] [Save heaps of Mb] [How to mock strip] [Cool Insert Clips]

Real useful info - [FAQ INDEX] [Compression explained] [Logical Remapping of Enabled Streams] [DVD-Replica] [Fantastic info on DVDs]


You should only use genuine Verbatim or Taiyo Yuden media. Many thanks to www.pcx.com.au for their supply and great service.

Explore the sites and the programs - there's a gold mine of information in them

Don't forget to play the Digital Digest Quiz!!! (Click here)

blutach is offline  
Old 15 Dec 2008, 11:44 PM   #3
Junior Member
Junior Member
 
Join Date: Dec 2008
Posts: 4
Default

Thank you.

I look to the MPEG-TS streams (with wiresahark). I didn't find the Picture Hearder in the MPEG Headers.
What I found is only the stream ID (0xE0) which is the MPEG-2 stream ID followed by the its extension. That's all .

Can I do something with these fields ?

tkx
sarnov is offline  
Old 16 Dec 2008, 09:17 AM   #4
Not a god of digital video
 
blutach's Avatar
 
Join Date: Oct 2004
Location: is everything!
Posts: 24,628
Default

You should have a stream start code (01e0) followed by data, then the MPEG sequence header code (01b3) followed by data, then the 0x0100 picture header should be around byte 0x80. Look at it in a hex editor.

Regards
blutach is offline  
Old 18 Dec 2008, 12:13 AM   #5
Junior Member
Junior Member
 
Join Date: Dec 2008
Posts: 4
Default

Yeah !! I think I get it .

Thank's for the help. Maybe I'll come back here if I'll face a problem again.

Regards.
sarnov is offline  
Old 18 Dec 2008, 07:23 AM   #6
Not a god of digital video
 
blutach's Avatar
 
Join Date: Oct 2004
Location: is everything!
Posts: 24,628
Default



Regards
blutach is offline  
Old 3 Jan 2009, 11:34 PM   #7
Junior Member
Junior Member
 
Join Date: Dec 2008
Posts: 4
Default

Hi,

Sorry I didn't find the Picture Header in this ts file. The picture hearder start with someting like that 00 00 01 00. Maybe you should look on another part of your ts file.

Sarnov.
sarnov is offline  
Old 11 Feb 2009, 11:04 PM   #8
Junior Member
Junior Member
 
Join Date: Dec 2008
Posts: 2
Default I Frame identification

Hi,

Finally I found out how to identify iframes from a ts file. In a typical video ts file you'll encounter something like the following:

(in hex)
00 00 00 01 E0 --> This indicates the start of video PES packet
..
..
00 00 01 B8 --> This indicates start of group of pictures header
..
..
00 00 01 00 --> This indicates the picture start code as said by Blutach in the previous post. This is 32 bits. The 10 bits immediately following this is called as the temporal reference. So temporal reference will include the byte following the picture start code and the first two bits of the second byte after the picture start code ie one byte(8 bits) + 2 bits. These we need to skip. Now the three bits present(3, 4 and 5th bits of the second byte from the picture start code) will indicate the Frame type ie I, B or P. So to get this simply logical AND & the second byte from the picture start code with 0x38 and right shift >> with 3. Voila.. you get your frame type!!

For example assume I've identified the picture start code. Now my data will be something like this:

00 00 01 00 00 0F FF F8 00 00 01 B5........... and so on.

Here the first four bytes 00 00 01 00 is the picture start code.
The fifth byte and the first two bits of the sixth byte is the temporal reference.
So our concern is in the sixth byte --> 0F
Frame type = ((0F & 38)>>3);
Frame type = 1 ==> I Frame

For further info:
Frame type = 000 forbidden
Frame type = 001 intra-coded (I) - iframe
Frame type = 010 predictive-coded (P) - p frame
Frame type = 011 bidirectionally-predictive-coded (B) - b frame
Frame type = 100 shall not be used(dc intra-coded (D) in ISO/IEC11172-2)
Frame type = 101 reserved
Frame type = 110 reserved
Frame type = 111 reserved

I hope this would help.

Last edited by bluegenetic; 12 Feb 2009 at 01:59 AM Reason: Modified to support previous post
bluegenetic is offline  
Old 12 Feb 2009, 12:13 AM   #9
Not a god of digital video
 
blutach's Avatar
 
Join Date: Oct 2004
Location: is everything!
Posts: 24,628
Default

Is that not what I said in posts 2 & 4?

Regards
blutach is offline  
Old 12 Feb 2009, 01:52 AM   #10
Junior Member
Junior Member
 
Join Date: Dec 2008
Posts: 2
Default

Dear Blutach,

What you said was perfectly right! In fact what you gave was the only source which I found effective for extracting iframes while searching from google. But I recently happened to get a copy of the ISO doc of MPEG TS. I just wanted to elaborate on what you said. I didn't mean to offend you.

Kindly excuse and forgive me if I've hurted you.

With cheers,
Bluegenetic
bluegenetic is offline  
Old 12 Feb 2009, 06:21 AM   #11
Not a god of digital video
 
blutach's Avatar
 
Join Date: Oct 2004
Location: is everything!
Posts: 24,628
Default

Nothing to forgive blugentetic!

Regards
blutach is offline  
Old 10 Sep 2009, 04:26 PM   #12
Junior Member
Junior Member
 
Join Date: Sep 2009
Posts: 8
Default

Hi guys,
thanks for the great post.. I was wondering.. Has anybody tried to analyize the Adaptation Field in the MPEG2-TS ? And how is that we can find the sequence of a particular program as in sequence of the package .. As in first we find the PAT, then its find the PMT's and then how is that we figure out the Elementary Streams in sequence??
ruby33 is offline  
Old 14 Sep 2009, 04:39 PM   #13
Junior Member
Junior Member
 
Join Date: Sep 2009
Posts: 1
Default hi

hello guys thanks for your post
pollyanna03 is offline  
Old 23 Sep 2009, 05:50 PM   #14
Junior Member
Junior Member
 
Join Date: Sep 2009
Posts: 8
Default

Hi for better understanding i started using an Mpeg-ps stream.
Now in the PS stream i have i only seems to see Stream types with ID
E0,C0 and BE... Can i get the iframes from the same?? If so it will be of great help..
Thanks
ruby33 is offline  
Old 24 Sep 2009, 03:37 PM   #15
Junior Member
Junior Member
 
Join Date: Sep 2009
Location: EU
Posts: 6
Default

ruby33, I have a similar situation in my stream..
In your case, the E0 stream is the video stream.
Here's how I'm decoding (looking at the stream in wireshark) the ISO 13818-1 packet:
- header - 4 bytes
- packetized elementary stream - 4 bytes, the last byte is the stream ID
- PES extension - 4 bytes
- PES header data length - 1 byte
- PES header data - whatever the previous value was
- PES data - whatever is left to 188 being total packet length..

Now in the PES data I see the 1st 4 octets being 00 00 01 00, which is the Picture Header, then 2 octets being e.g. 00 5B. The octet 5B is 0101 1011 which gives me the B frame.

What is strange, though, decoding the data I have I only see P and B frames, no I frames.

Last edited by mehturt; 24 Sep 2009 at 06:47 PM
mehturt is offline  
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MKV Extract Gui 1.5 can't extract certain file Shadowofthedark Junior Members/Newbies 11 16 Oct 2006 11:07 AM
3ivx mov to mpeg2 (and possibly cropping mpeg2) primate1 Other File Formats 4 10 Mar 2005 04:49 PM
Extract MPEG2 (chapters to single files) from authored DVD (on HD dir) kamac DVD Authoring and Editing 4 24 Feb 2004 04:35 PM
Xvid Avi Bad Frames how i extract?? Aranthi AVI, DivX/Xvid 5 1 May 2003 08:05 AM



All times are GMT +10. The time now is 11:03 PM.

Kirsch designed by Andrew & Austin


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0
Copyright © 1999 - 2011 Digital Digest

Visit DivXLand   Visit dvdloc8.com