0

I am currently sending individual NAL units across a network. These NAL units are generated by x264. Now is it possible to feed these NAL units individually into avcodec_decode_video2?

Or do I have to concatenate the nal units until they represent the same frame? If thats the case then how is that done?

I have also read that I might be able to receive the SPS and PPS packets. Then wait for at least one packet, and attempt to decode. Is this correct?

Any advice that can be offered would be greatly appreciated

2 Answers2

1

Yes, it is possible for us to pass the NAL units individually to the decoder. H264 has the capability to split into multiple slices with multiple NAL units per frame. Pl. refer to the tutorial which provides steps to decode using ffmpeg. http://dranger.com/ffmpeg/tutorial01.html.

Also check the output of the av_read_frame call to understand how the frame data is coming. Suggest you pl. refer to the below stack overflow link which also explains the issue with NAL decoding H264: decode series of nal units with ffmpeg

Community
  • 1
  • 1
shri
  • 856
  • 1
  • 10
  • 26
  • The tutorial uses av_read_frame(), but I am not reading from a file. Does this method still work with NAL units coming across a network? The SPS and PPS are all individual packets that I am sending out to the network, x264 is giving me 1300 byte slices. So none of my NAL lengths are above that size. – madprogrammer2015 Jun 01 '15 at 14:16
  • int av_read_packet (AVFormatContext * s,AVPacket * pkt) was used, before to read the packet data, but now it is obsolete. And we have to use the av_read_frame(). Pl. refer to the below link http://ffmpeg.sourcearchive.com/documentation/0.6/libavformat_2utils_8c_bad7a4517e0be66e41f32c3c0b2454a4.html – shri Jun 05 '15 at 08:45
-1

I had a similar issue - Setting the key_frame on the packet solved any NAL issues. Also make sure you set the extra data in the codec context.