Dear experts,
I'm currently trying to decode raw H.264 video data from memory but my
application keeps crashing when calling av_decode_video. My code looks
as follows:
av_register_all();
[..]
AVFormatContext *formatcontext;
AVCodecContext *codeccontext;
AVFormatParameters *ap =
(AVFormatParameters*)malloc(sizeof(AVFormatParameters));
memset(ap, 0, sizeof(AVFormatParameters));
ap->width = KnownWidth;
ap->height = KnownHeight;
ap->sample_rate = KnownFrameRate;
AVInputFormat *inputformat = av_find_input_format("h264");
if (!inputformat)
//(removed) Error handling
inputformat->flags |= AVFMT_NOFILE;
if (av_open_input_file(&formatcontext, "", inputformat, 0, ap) != 0)
//(removed) Error handling
for (unsigned int i = 0; i < formatcontext->nb_streams; i++)
{
if (formatcontext->streams[i]->codec->codec_id == CODEC_ID_H264)
{
//(removed) Print info about the stream found (this seems to work)
codeccontext = formatcontext->streams[i]->codec;
}
}
[..]
//At this point, VideoData is a buffer containing VideoSize bytes of
valid H.264 video data (should be exactly one IDR frame on startup)
int finished = 0;
AVFrame *frame = avcodec_alloc_frame();
if (!frame)
//(removed) error handling
avcodec_decode_video(codeccontext, frame, &finished, VideoData,
VideoSize); //During this call the application crashes
if (finished)
{
//TODO: do something here
}
What is wrong with my code so that it causes the function to crash? I
also tried creating a pipe and piping the data into it, using
pipe://<fileno> as file name, but this didn't work out either. Any
ideas?
Regards,
Andreas
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user