[Ffmpeg-devel] Encoding IBBP MPEG2 with fixed gop size.

Thomas Parmegiani thomasp
Wed Oct 25 17:15:53 CEST 2006


> -----Message d'origine-----
> De : ffmpeg-devel-bounces at mplayerhq.hu
> [mailto:ffmpeg-devel-bounces at mplayerhq.hu]De la part de Michel Bardiaux
> Envoy? : mercredi 25 octobre 2006 16:58
> ? : FFmpeg development discussions and patches
> Objet : Re: [Ffmpeg-devel] Encoding IBBP MPEG2 with fixed gop size.
>
>
> Thomas Parmegiani wrote:
> > Hi all !
> >
> > I try encode a file to have a MPEG2 IBBP with a fixed gop size (12) :
> >
> > If I use ffmpeg : ./ffmpeg -i /G/video.ts -minrate 20000K -maxrate
> > 20000K -bufsize 2000K -b 20000K -flags2 sgop -bf 2 -g 12 /G/test.ts
> >
> > It works. I checked the source code it seems ffmpeg set AVCodecContext
> > flags2 value to CODEC_FLAG2_STRICT_GOP. If I do the same thing on my
> > application it does not work.
>
> It does not work *HOW*? My crystal ball is in the repair shop...

 ;D
>
> > So I guess I have to set another parameter but
> > which one ? Anybody can help me ?
>
> Do you use avcodec_get_context_defaults in your app?

Yes this function is called by avcodec_alloc_context() function.
Please read below to see parameters I set to prepare encoding :

...

AVCodecContext *ovc;

ovc = avcodec_alloc_context();

ovc->codec_type	   = CODEC_TYPE_VIDEO;
setTimeBase(ovc, m_ic->streams[m_iStream]->r_frame_rate.den,
m_ic->streams[m_iStream]->r_frame_rate.num);
ovc->me_method       = ME_EPZS;
ovc->pix_fmt         = PIX_FMT_YUV420P;
ovc->width           = m_ic->streams[m_iStream]->codec->width;
ovc->height          = m_ic->streams[m_iStream]->codec->height;

if (m_iInterlace == 1)
	ovc->flags = CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME;
ovc->gop_size        = 12;
ovc->max_b_frames    = 2;
ovc->sample_aspect_ratio = dec->sample_aspect_ratio;
ovc->mb_decision = 1;
ovc->bit_rate_tolerance = 1;
ovc->qmin = 2;
ovc->bit_rate = 25000000;
ovc->rc_max_rate = ovc->bit_rate;
ovc->rc_min_rate = ovc->bit_rate;
ovc->flags2 = CODEC_FLAG2_STRICT_GOP;
ovc->rc_buffer_size     = ovc->bit_rate/10;

ovcodec = avcodec_find_encoder(CODEC_ID_MPEG2VIDEO);
iResult = avcodec_open(ovc, ovcodec);

...




> >
> > Best Regards,
> >
> > Thomas.P
>
> Greetings,
> --
> Michel Bardiaux
> R&D Director
> T +32 [0] 2 790 29 41
> F +32 [0] 2 790 29 02
> E mailto:mbardiaux at mediaxim.be
>
> Mediaxim NV/SA
> Vorstlaan 191 Boulevard du Souverain
> Brussel 1160 Bruxelles
> http://www.mediaxim.com/
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>
> __________ Information NOD32 1.1832 (20061025) __________
>
> Ce message a ete verifie par NOD32 Antivirus System.
> http://www.nod32.com
>
>





More information about the ffmpeg-devel mailing list