On Sat, 4 Jul 2009 22:56:46 +0530, Umakant Goyal
<[email protected]> wrote:
>    I am using avcodec_encode_video API to encode data into MPEG4
> format. But when i display encoded data after decoding it then i find
> lines over frame.

Can you elaborate on this?

>    And Video Quality is also not so good.
>    I tried lot to figure out the problem.But could not succeeded.
>    I have opened the codec wit h following parameters:
>    AVCodecContect **apContect;
>    /* Some code missing */
>             (*apContext)->bit_rate = 90000;
>             (*apContext)->profile = 0;                  /* New */
>             (*apContext)->pix_fmt = PIX_FMT_YUV420P;
>             (*apContext)->codec_id = CODEC_ID_MPEG4;        /* New */
>             (*apContext)->codec_type = CODEC_TYPE_VIDEO;
>             (*apContext)->width = 352;//img->width;
>             (*apContext)->height = 288;//img->height;
>             (*apContext)->time_base.den = 1;
>             (*apContext)->time_base.num = 30;
>             (*apContext)->gop_size = 30;

Unless you need a 'short' GOP for seeking purposes, it's 'usual' for
MPEG-4 and h.264 to have GOPs around 10 seconds of frames at their
maximum.

>             (*apContext)->qmin = 4;//max_b_frames = 1;

I would advise against altering qmin and qmax.

>             (*apContext)->mpeg_quant = 0;
>             (*apContext)->qmin = 20;
>             (*apContext)->qmax = 20;

As above. Though with these set, the quantiser would be fixed at 20,
which would undoubtedly look very bad for MPEG-4 Part 2.

>             (*apContext)->qcompress = 0;
>             (*apContext)->qblur = 0;
>             (*apContext)->max_qdiff = 0;
> 
>             (*apContext)->max_b_frames = 0;
>             (*apContext)->mpeg_quant = 0;

This setting is duplicated from above, but I would recommend not
setting these unless you know what you're doing and that you should set
them.

>             (*apContext)->flags|=CODEC_FLAG_4MV;

This one is actually useful.

>             (*apContext)->flags|=CODEC_FLAG_H263P_UMV;

This doesn't apply to MPEG-4 Part 2.

>             (*apContext)->flags|=CODEC_FLAG_GMC;

Use of GMC is discouraged for MPEG-4 Part 2.

> (*apContext)->flags|=CODEC_FLAG_LOOP_FILTER;//(*apContext)->bit_rate_tolerance
> = bitRate << 3;

MPEG-4 Part 2 does not have a loop filter.

>             (*apContext)->flags|=CODEC_FLAG_H263P_SLICE_STRUCT;

This does not apply to MPEG-4 Part 2.

>             (*apContext)->rc_min_rate = 0; // minimum bitrate
>             (*apContext)->max_qdiff = 3; // max q difference between
> frames (*apContext)->rc_qsquish = 0; // limit q by clipping
>             (*apContext)->rc_eq= "tex^qComp"; // rate control equation
>             (*apContext)->qcompress = 0.5;
>             (*apContext)->i_quant_factor = (float)-0.6;
>             (*apContext)->qmax = 24;
>             (*apContext)->i_quant_offset = (float)0.0;

These aren't particularly convincing either.

I suggest that you follow the code in ffmpeg.c for initialising an
encoder. Load the defaults and then set the equivalent of '-cmp 2
-subcmp 2 -mbd 2 -trellis 1 -g 300' as well as all the other necessary
parameters for resolution, pixel format, bit rate, frame rate and so
on. Also note that 90kbps is a low bit rate for 352x288 30fps video.

Regards,
Rob
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to