问题
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.
回答1:
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.
回答2:
Start codes are not a fixed size and can be 3 or 4 bytes. Read more here: https://stackoverflow.com/a/24890903/660982
来源:https://stackoverflow.com/questions/23404403/need-to-convert-h264-stream-from-annex-b-format-to-avcc-format