[FFmpeg-devel] h264 decoding question

Jimmy Bhaktha jimmy at accelrobotics.com
Mon Sep 24 19:43:43 EEST 2018


Hi

I am working on an application based on FFMPEG version 3.4.2 where the RTSP
packets from the camera are captured and store using python. The decoder
application is run later.  The application receives a  byte array which is
the actual packet. The goal is to decode the received packet and convert it
to RGB from YUV.

When I feed it packets I see the following output

Creating the codec h264
Creating the codec context
[h264 @ 0x557a3846d880] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x557a3846d880] nal_unit_type: 8, nal_ref_idc: 3


[h264 @ 0x557a3846d880] nal_unit_type: 5, nal_ref_idc: 3


[h264 @ 0x557a3846d880] Reinit context to 2688x1520, pix_fmt: yuvj420p


avcodec_send_packet=0


avcodec_receive_frame=0, pCodecCtx->frame_number=1
[swscaler @ 0x557a385fdb20] bad src image pointers
201


[h264 @ 0x557a3846d880] nal_unit_type: 1, nal_ref_idc: 3
[h264 @ 0x557a3846d880] nal_unit_type: 0, nal_ref_idc: 0


[h264 @ 0x557a3846d880] Unknown NAL code: 0 (103 bits)


avcodec_send_packet=0


avcodec_receive_frame=0, pCodecCtx->frame_number=2
[swscaler @ 0x557a385fdb20] bad src image pointers

I was wondering why I am getting the unknown NAL code. Also wondering why
the swscaler is complaining about bad src images.

Here is the sequence of calls in my code

1.  av_packet_alloc() and av_packet_init()
     - copy the encoded image to packet->data (I extend it by
AV_INPUT_BUFFER_PADDING_SIZE and set the memory to zero
2.  av_register_all();
3.  Create the codec and Codec Context for h264 and open it.
    - I Copy the extra data from the encoded frame to this context.
4. Allocate the memory for the frames (YUV and RGB)
5. First time using the coded I call decode - I see the codec context now
has the correct values for height and width.
    - For decoding I use the avcodec_send_packet and check in a while loop
for avcodec_receive_frame() I see the number of decoded frames in the codec
context goes up (pCodecCtx->frame_number)
6. Use this codec context to set up the sws_context
7. Use the sws_context and the YUV frame decoded to get the RGB frame.


I based the code on the ffmpeg decoding_video,cpp example and the tutorial
at http://dranger.com/ffmpeg/tutorial01.html . I am trying to figure out
why I am getting the errors above.
Thanks for your help in advance.

-- 
Jimmy Bhaktha


More information about the ffmpeg-devel mailing list