Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the relationship between AVPacket in FFMpeg and H.264 NAL Uint?

I use FFMpeg's api to encode images to H.264 stream, the code is like this encode code. When I called the function avcodec_encode_video2 I got one AVPacket's data, then I saved it to file. I use several images to get several files for test. Based on the startcode 00 00 00 01 or 00 00 01, I found that the 1st and 2nd files' data both contain several H.264 NAL Uints. But start from the third file, I can't found the startcode. Like followed image. Picture

I feel confused. Base on the FFMpeg's code I think one AVPacket's data should contain at least one NAL Uint, but the result is unexpected. Is that means one NAL Uint may be divided to two AVPackets' data? What's the relationship between AVPacket and H.264 NAL Uint?

like image 324
Ello Avatar asked Jun 02 '16 07:06

Ello


1 Answers

00 00 00 01 41.....
........00 00 01 41
....00 00 01 41......
.......

After I tested, except the beginners, the following NAL all separated by 00 00 01, and NAL type is same, too. So each AVPacket should include one NAL at least.

like image 132
androidwifi Avatar answered Nov 13 '22 19:11

androidwifi