View Full Version : H.264 convert from bitstream to bytestream [annex b]
aviadr1
27th April 2009, 09:54
Hi,
as $subj
I tried just replacing the 4-byte nal-size with an 00 00 00 01 startcode but it didnt work.
does anyone have sample code to do this conversion or can explain what I'm missing?
Aviad
Guest
27th April 2009, 14:45
Perhaps you nade a coding error (such as assuming that the length value includes the length field).
I do the same thing to support MKV files. For each extracted frame (b points to the extracted frame buffer), I do this:
// Convert to Annex B NALUs if necessary.
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);
}
aviadr1
27th April 2009, 15:42
it works, thanks!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.