Hello.<br> I am using ffmpeg 20110816 git version on windows. <br> I am trying to do an application get camera frame from directshow then encode it into h264 stream. <br> Here is what I am doing:<br>1. Get frame from directshow pin<br>
which is in YUYV12 format (YUV422). <br>2. sws_scale the frame into YUV420P format<br>3. encode YUV420P into h264 format.<br>The problem is after the encode start, the avcodec_encode_video always return 0 until pass frame 42, then each frame generate 1 encoded frame.<br>
here is the code.<br><br>pEnCodecCtx = avcodec_alloc_context3(NULL);<br>pEnCodecCtx->gop_size = 25; <br> pEnCodecCtx->time_base.den = 25;<br> pEnCodecCtx->time_base.num = 1;<br>pEnCodecCtx->width = m_iWidth;<br>
pEnCodecCtx->height = m_iHeight;<br> pEnCodecCtx->pix_fmt = PIX_FMT_YUV420P;<br>pEnCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;<br>ideo_outbuf_size = 200000;<br> <br> AVCodec *t_codec;<br> t_codec = avcodec_find_encoder(CODEC_ID_H264);<br>
<br> if(avcodec_open(pEnCodecCtx, t_codec) < 0){<br> printf("Error open code\n");<br> exit(1);<br> }<br><br><br><br>Then encode<br>ret = avcodec_encode_video(pEnCodecCtx,video_outbuf,video_outbuf_size,pictureDst);<br>
<br>the ret is 0 until I call encode_video from 42 times. <br><br>Why? Please help.<br><br><br>Thanks.<br>Regards.<br>Scott<br>