[Ffmpeg-devel] Cannot encode frame as rawvideo in an .avi file

Munier Nicolas Nicolas.Munier
Tue May 2 10:38:52 CEST 2006


Hi everyone,

 

I'm using the ffmpeg librairies to create an avi file containig one
rawvideo stream of UYVY frames.

I pretty much follow the example of ouput_example.c and I got a problem
using avcodec_encode_video. It returns -1.

 

00578
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/libavcodec_2utils_
8c.html#a38>  int avcodec_encode_video
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/libavcodec_2utils_
8c.html#a38> (AVCodecContext
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/structAVCodecConte
xt.html>  *avctx, uint8_t *buf, int buf_size, 
00579                          const AVFrame
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/structAVFrame.html
>  *pict)
00580 {
00581     if(buf_size < FF_MIN_BUFFER_SIZE){
00582         av_log
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/libavcodec_2utils_
8c.html#a55> (avctx, AV_LOG_ERROR
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/avcodec_8h.html#a2
38> , "buffer smaller then minimum size\n");
00583         return -1;
00584     }
00585     if(avcodec_check_dimensions
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/libavcodec_2utils_
8c.html#a25> (avctx,avctx->width
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/structAVCodecConte
xt.html#o9> ,avctx->height
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/structAVCodecConte
xt.html#o10> ))
00586         return -1;
00587     if((avctx->codec
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/structAVCodecConte
xt.html#o30> ->capabilities
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/structAVCodec.html
#o6>  & CODEC_CAP_DELAY) || pict){
00588         int ret = avctx->codec
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/structAVCodecConte
xt.html#o30> ->encode
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/structAVCodec.html
#o3> (avctx, buf, buf_size, (void *)pict);
00589         avctx->frame_number
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/structAVCodecConte
xt.html#o17> ++;
00590         emms_c
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/dsputil_8h.html#a1
1> (); //needed to avoid an emms_c() call before every return;
00591     
00592         return ret;
00593     }else
00594         return 0;
00595 }

 

My rawvideo codec is correctly open; I have a pointer to a decode
function. My UYVY AVFrame is also correctly filled.

My buf is correctly allocated and its size is correct.

I also notice that frame_number from my CodecContext is incremented
after avcodec_encode_video
<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/libavcodec_2utils_
8c.html#a38> . So it must be codec->encode which return -1. 

My question is: is there some kind of problem encoding rawvideo or is
there an error in my init which could lead to that?

 

Regards,

 

Nicolas





More information about the ffmpeg-devel mailing list