Reputation: 669
I am looping through a list of H264 NAL header slices for a raw H264 file. While looping through, I am printing out the "slice_type" (iframe = I, pframe = P, or bframe = B) and the "frame_num" (number of the frame in the sequence). The sequence is different for each raw H264 file but, as you can see below, each pattern resets the "frame_num" after a certain "frame_num" count. For this sequence, it resets after "frame_num" 15 then after "frame_num" 10 then 15 then 10 etc etc. The framerate of this particular H264 is 30. There are 44 '0' "frame_num" and 659 total "frame_num" with about 15 '0' for every other type of "frame_num".
Do any of you know what this sequence of "frame_num" means or why it is reseting? I am hypothesising that each reset is half of a video frame but I am not exactly sure.
I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, I,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15, P,0, P,1, P,2, P,3, P,4, P,5, P,6, P,7, P,8, P,9, P,10, P,11, P,12, P,13, P,14, P,15
Upvotes: 1
Views: 2073
Reputation: 13317
The number is for keeping track of the relative order of frames, for cases with reordering (such as with B-frames). It's resetting because it's only a few bits long, so in your case, after 15 it wraps around to 0. Since the receiver knows how many bits it is, it can also know that 0 is the next frame after 15, and given a short window of frames, e.g. 13, 14, 15, 0, 1, 2, it knows what the right order of those frames are.
Additionally, on IDR frames it also restarts from 0, since frames after those don't depend on the previous ones.
Upvotes: 2