[Libav-user] Change a Resolution of a Video

Diego Carvalho Domingos diego.cdomingos2010 at gmail.com
Wed Apr 27 21:21:38 CEST 2011


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.


More information about the Libav-user mailing list