Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
655 views
in Technique[技术] by (71.8m points)

h.264 - Need to convert h264 stream from annex-b format to AVCC format

I need to convert h264 stream from annex-b format to AVCC format.

I tried this to convert from h264 annex-b to AVCC: I extracted the SPS and PPS from the annex stream and created the Extra data. I then looked in the stream for 0x00 0x00 0x00 0x01 (which should be the start of each Nal) and continue looking for another 0x00 0x00 0x00 0x01 (which will be the end of the Nal) then did minus to get the Nal length, then replace the first 0x00 0x00 0x00 0x01 to 0x00 0x00 0x00 [NulSize] but seems that this does not produce valid stream. I then found out that NUL can starts/ends with 0x00 0x00 0x01 so i am little confused.

anyway, I hope someone will be able to write me function that convert from annex-b to AVCC.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

NALU is basic unit.

Then,

annexb format:

([start code] NALU) | ( [start code] NALU) |

avcc format:

([extradata]) | ([length] NALU) | ([length] NALU) |

In annexb, [start code] may be 0x000001 or 0x00000001.

In avcc, the bytes of [length] depends on NALULengthSizeMinusOne in avcc extradata, the value of [length] depends on the size of following NALU and in both annexb and avcc format, the NALUs are no different.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...