[Libav-user] Decoding, rescaling and reecoding

Diego Carvalho Domingos diego.cdomingos2010 at gmail.com
Wed May 18 20:22:18 CEST 2011


I have a complex task to do. I'm receiving h264 rtp packets from the
internet and I need to change their resolution before forwarding them.
I've created a class to create a frame from the packets, decode it
with libavcodec, rescale it with libswscale, reencode it, again with
libavcodec, that uses libx264 (I couldn't get it working using x264
directly), and finally convert the frame to packets again and forward
them. It's working (altough with bad quality) but I get a segfault in
a random moment in libswscale. Another issue is that I am not sure
about the parameters (AVCodecContext) I am using to encode (I couldn't
find much information about this on the internet) and I think that it
is the reason of the bad quality video:
encoderCtx->bit_rate = 400000;
encoderCtx->me_method = ME_HEX;
encoderCtx->time_base.num = 1;
encoderCtx->time_base.den = 25;
encoderCtx->width = outWidth;
encoderCtx->height = outHeight;
encoderCtx->gop_size = 10;
encoderCtx->pix_fmt = PIX_FMT_YUV420P;
encoderCtx->qcompress = 0.6;
encoderCtx->qmin = 1;
encoderCtx->qmax = 10;
encoderCtx->max_qdiff = 4;
encoderCtx->max_b_frames = 1;
encoderCtx->me_range = 16;
I don't even know if this is the best solution to achieve my goal (Is
there a way to rescale a h264 frame without decoding it?). I
appreciate any help or suggestions. As I am new using libavcodec, I
appreciate any links with examples about how to decode, scale and
encode as well (everything that i could get working I found in the
internet, so I am not sure if everything is fine). Thanks.


More information about the Libav-user mailing list