I'm receving RTP Data in a buffer and trying to decode the data inside this buffer using avcodec_decode_video2(). However I seem to be getting an error when calling this function:
Exception thrown at 0x10086F50 (avcodec-57.dll) in RTSP Video Application.exe: 0xC0000005: Access violation reading location 0x0000005C.
void video_decode(unsigned char * RTPData)
{
AVCodecContext *m_pCodecCtx;
AVCodec *m_pCodec;
AVFrame *m_pFrame;
m_pCodec = avcodec_find_decoder(AV_CODEC_ID_H264);
m_pCodecCtx = avcodec_alloc_context3(m_pCodec);
avcodec_open2(m_pCodecCtx, m_pCodec, 0);
m_pFrame = av_frame_alloc();
AVPacket packet;
av_init_packet(&packet);
packet.data = RTPData;
packet.size = (int)sizeof(RTPData);
packet.flags |= AV_PKT_FLAG_KEY;
int framefinished = 0;
avcodec_decode_video2(m_pCodecCtx, m_pFrame, &framefinished, &packet);
}
Edit: Is this function the correct way to decode RTP Data, and if so, why am I getting an Access violation when calling avcodec_decode_video2()?
User contributions licensed under CC BY-SA 3.0