1

In my situation, iOS HW encoder sometimes generates one nalu and other times generates two nalus which make up the access-unit/picture. When two nalus were generated for one picture, I combine them two by replacing the first nalu's start code with the size of the total size of these two nalus and removing the start code the second nalu and appending it to the end of first nalu. Just like this, 0x00000002aaaa and 0x00000002bbbb become 0x00000004aaaabbbb. But the video shows blurred on the screen. So does someone can teach me how to combine nalus correctly? Great thanks.

Two nalus for one frame like this(almost same as data from this link( https://forums.developer.apple.com/thread/14212?sr=stream), so I just copy it): enter image description here

Here I want combine #1 and #2.

1 Answers1

2

Each NALUs needs a size, you can not concatenate them.

You must do 00000002aaaa00000002bbbb

szatmary
  • 29,969
  • 8
  • 44
  • 57
  • thanks for your answer. It seems that ffmpeg will put two nalus next to each other like 0x00 00 00 01 aa aa, 0x00 00 01 bb bb together turning out be one AVPacket. Here I need to do this by myself. – fernandowei May 08 '16 at 06:51
  • Only for annex b. Don't mix avcC and annex b. – szatmary May 08 '16 at 07:35
  • No I mean earthier uses a start code, or a size when constructing a stream, not a combination. If you are writing a .264 or a .ts use start codes. If an MP4, use size values. – szatmary May 08 '16 at 07:54
  • thanks, you mean only annex b style nalus can be combined not avcC? However, I got no idea except combining two avcC style nalus of one frame generated by iOS HW encoder to fix the blurred video. Crying............ – fernandowei May 08 '16 at 07:55