Try using swscale to scale the image to the size you want. It does this losslessly and makes sure that the stride counts are correct. It stands for Software Scaling by the way, which can be found in libswscale. It's very fast, too, so learning how to use it would be a major help to yourself.<br>
<br><div class="gmail_quote">On Wed, Apr 27, 2011 at 12:21 PM, Diego Carvalho Domingos <span dir="ltr"><<a href="mailto:diego.cdomingos2010@gmail.com">diego.cdomingos2010@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Is it possible to change a resolution of a video using libavcodec? In<br>
my case, I want to change the resolution of a h264 video from 320 x<br>
240 to 640 x 480. I basically made some changes in the api-example.c.<br>
I'm trying to decode the video (using avcodec_decode_video2) and<br>
reenconde it (using avcodec_encode_video, with ffmpeg compiled with<br>
--enable-libx264), using CODEC_ID_H264 and setting the AVCodecContext<br>
as follow:<br>
    CodecCtx->bit_rate = 400000;<br>
    CodecCtx->width = 640;<br>
    CodecCtx->height = 480;<br>
    CodecCtx->time_base.num = 1;<br>
    CodecCtx->time_base.den = 25;<br>
    CodecCtx->me_range = 16;<br>
    CodecCtx->max_qdiff = 4;<br>
    CodecCtx->qmin = 10;<br>
    CodecCtx->qmax = 51;<br>
    CodecCtx->qcompress = 0.6;<br>
    CodecCtx->gop_size = 10;<br>
    CodecCtx->max_b_frames=1;<br>
    CodecCtx->pix_fmt = PIX_FMT_YUV420P;<br>
but I'm receiving the following error:<br>
Input picture width (640) is greater than stride (352)<br>
I didn't understand because my input is a 320 x 240 video.<br>
Actually, if I don't change the resolution (I mean, set<br>
CodecCtx->width to 320 and CodecCtx->height to 240) the video is<br>
reencoded but with a really bad quality, so probably the settings are<br>
wrong (I found them on the internet). I'm new using libavcodec, so I<br>
apreciate any help. Thanks in advance.<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Spencer Graffe<br>- A Guy<br>