Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
16th March 2009, 21:40 | #1 | Link |
Registered User
Join Date: Aug 2005
Location: Istanbul, Turkey
Posts: 66
|
AVC Keyframe search
Hi. I wanted to identify key frames in AVC steam. Specially in AVI file.
In MPEG4-ASP, there is a flag (first byte) that indicates if its key frame or not. In MPEG4-AVC, first byte is always 0x01000000. How can I get information about h264 format? Specially about how its frames constructed. Thank you. |
16th March 2009, 22:12 | #2 | Link |
Software Developer
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
|
This document may be helpful:
http://www.itu.int/rec/dologin_pub.a...F-E&type=items The Bitstream Format is defined in Annex B.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ |
16th March 2009, 22:27 | #3 | Link |
Mr. Sandman
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
|
and FCS dont place AVC in AVI...
__________________
MPEG-4 ASP Custom Matrices: EQM V1(old), EQM AutoGK Sharpmatrix (aka EQM V2), EQM V3HR (updated 01/10/2004), EQM V3LR, EQM V3ULR (updated 04/02/2005), EQM V3UHR (updated 17/12/2004) and EQM V3EHR (updated 05/10/2004) Info about my ASP matrices. MPEG-4 AVC Custom Matrices: EQM AVC-HR Info about my AVC matrices My x264 builds. Mooo!!! |
30th August 2009, 00:08 | #5 | Link |
Registered User
Join Date: Aug 2005
Location: Istanbul, Turkey
Posts: 66
|
I think I am in trouble.
I detect some of keys but I don't understand its logic. 0x00 0x00 0x00 0x17 0x67 -> IDR frame OK 0x00 0x00 0x00 0x18 0x67 -> This is IDR too. I study sheet that you linked, But those frames not comfort "0x000001" or "0x00000001" start_code_prefix_one_3bytes. I inspect some codes but I didn't understand. Could you indicate that where I am making mistake? I am thinking that 00 00 00 18 conform with specsheet but dividing bytes from half not came logic to me. Do you know anything about this frames? |
30th August 2009, 02:49 | #7 | Link |
Registered User
Join Date: Aug 2005
Location: Istanbul, Turkey
Posts: 66
|
I am trying to parse in AVI directly.
Those are RAW AVC frame beginnings in AVI. 00dc[4byte frame size ] then [0x00 0x00 0x00 0x17 0x67 ....] But this also true for MKV. I got same values on MKV SimpleBlock or Blocks [0x00 0x00 0x00 0x17 0x67 ....] Now which part is "start code prefix" or where is nal_ref_idc. I think data[4]=0x67 is 7 is nal_unit_type Last edited by Death KnightŪ; 30th August 2009 at 03:20. |
30th August 2009, 03:03 | #8 | Link |
Software Developer
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
|
If the AVC stream is in AVI, then it's not raw! You need to parse the RIFF/AVI first and extract the actual "raw" AVC data. Then you can parse the AVC bitstream...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ |
30th August 2009, 14:35 | #10 | Link |
Registered User
Join Date: Aug 2005
Location: Istanbul, Turkey
Posts: 66
|
I can't find any smaller AVC.
http://rapidshare.com/files/27342378..._Bomb.mkv.html |
30th August 2009, 15:02 | #11 | Link |
Guest
Join Date: Jan 2002
Posts: 21,901
|
First, NALU type 5 is an IDR, not 7.
Second, in MKV files, the NALUs are NOT delimited per Annex B, i.e., they do not use the 00 00 00 01 start code. Instead there is a 4-byte count that gives the length of the NALU. So you find the next NALU by jumping forward according to the count, instead of parsing for Annex B start codes. Here's a little code fragment from my MKV support in DGAVCIndexNV that converts the MKV NALU to an Annex B NALU for further processing. Code:
// Convert to Annex B NALUs. // b points to the buffer holding the MKV frame data. p = b; while (p < (unsigned char *) b + FrameSize) { nalu_len = (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3]; p[0] = 0; p[1] = 0; p[2] = 0; p[3] = 1; p += (nalu_len + 4); } Last edited by Guest; 30th August 2009 at 15:10. |
30th August 2009, 17:07 | #12 | Link |
Registered User
Join Date: Aug 2005
Location: Istanbul, Turkey
Posts: 66
|
Things became more clear. Thanks for that.
I am unaware that a AVC frame could have some other marks. I didn't understand SEQ_PARAM indicates this. I parsed one AVC MKV frame. Which start with SEQ_PARAM I believe... A0 BlockGroup A1 Block then 4 byte block header, painted with purple. Nalu sizes are in red. Now, for this MKV frame, it include 3 NALU, and their types are sequentially 7 (SEQ_PARAM), 8 (PIC_PARAM) then 5 (IDR_SLICE), right? I wish I understand correctly. |
30th August 2009, 21:06 | #13 | Link |
Guest
Join Date: Jan 2002
Posts: 21,901
|
Yes, you have it correct now.
>I didn't understand SEQ_PARAM indicates this. Not sure what you mean by this. There's nothing in the syntax (that I know of) to indicate what NALU delimitation is used. I just know that in MKV this method is used. If you want to post an AVI example, we can analyze that as well. But I think you have the idea. Last edited by Guest; 30th August 2009 at 21:10. |
1st September 2009, 00:11 | #14 | Link |
Registered User
Join Date: Aug 2005
Location: Istanbul, Turkey
Posts: 66
|
I thought SEQ_PARAM indicate that;
there is NALU sequence in this frame, there are more than one NALU for this frame. I checked some AVI. That uses same pattern with MKV. I think I converted that AVIs from MKV. Other AVIs follow Annex B pattern. Thanks for the help. |
1st September 2009, 01:59 | #15 | Link | |
Guest
Join Date: Jan 2002
Posts: 21,901
|
Quote:
So, specifically, with reference to the spec, what are you referring to? Or is this just something you overheard on a bus? And you're welcome. Happy to help you any time. |
|
Tags |
avc h264 keyframe |
|
|