[Libav-user] Change a Resolution of a Video

Spencer Graffe sgraffe at gmail.com
Thu Apr 28 01:51:19 CEST 2011


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.

On Wed, Apr 27, 2011 at 12:21 PM, Diego Carvalho Domingos <
diego.cdomingos2010 at gmail.com> wrote:

> Is it possible to change a resolution of a video using libavcodec? In
> my case, I want to change the resolution of a h264 video from 320 x
> 240 to 640 x 480. I basically made some changes in the api-example.c.
> I'm trying to decode the video (using avcodec_decode_video2) and
> reenconde it (using avcodec_encode_video, with ffmpeg compiled with
> --enable-libx264), using CODEC_ID_H264 and setting the AVCodecContext
> as follow:
>    CodecCtx->bit_rate = 400000;
>    CodecCtx->width = 640;
>    CodecCtx->height = 480;
>    CodecCtx->time_base.num = 1;
>    CodecCtx->time_base.den = 25;
>    CodecCtx->me_range = 16;
>    CodecCtx->max_qdiff = 4;
>    CodecCtx->qmin = 10;
>    CodecCtx->qmax = 51;
>    CodecCtx->qcompress = 0.6;
>    CodecCtx->gop_size = 10;
>    CodecCtx->max_b_frames=1;
>    CodecCtx->pix_fmt = PIX_FMT_YUV420P;
> but I'm receiving the following error:
> Input picture width (640) is greater than stride (352)
> I didn't understand because my input is a 320 x 240 video.
> Actually, if I don't change the resolution (I mean, set
> CodecCtx->width to 320 and CodecCtx->height to 240) the video is
> reencoded but with a really bad quality, so probably the settings are
> wrong (I found them on the internet). I'm new using libavcodec, so I
> apreciate any help. Thanks in advance.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>



-- 
Spencer Graffe
- A Guy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20110427/3e2c8de9/attachment.html>


More information about the Libav-user mailing list