Hi all,

First, I need to tell you that I am not familiar with the MPEG2 encoding parameters

I am working on an application that needs to be able to encode a file to a 60 Mbits MPEG2 CBR I-only file and it works pretty well.
Here are the ACodecContext encoding parameters I set :

//mybitrate has a value of 60 Mbits.

my_avcodeccontext_enc->bit_rate = mybitrate;//I want a 60 MBits/s file
my_avcodeccontext_enc->flags2 |= CODEC_FLAG2_STRICT_GOP;
my_avcodeccontext_enc->rc_max_rate = my_avcodeccontext_enc->bit_rate;//CBR
my_avcodeccontext_enc->rc_min_rate = my_avcodeccontext_enc->bit_rate;//CBR
my_avcodeccontext_enc->gop_size        = 0;
my_avcodeccontext_enc->max_b_frames    = 0;

my_avcodeccontext_enc->rc_buffer_size = ((40 * (my_avcodeccontext_enc->bit_rate/1000000))/1.15) * 8 * 1024;//((40 * my_avcodeccontext_enc->bit_rate)/1.15) / 1000000.0 * 8 * 1024; my_avcodeccontext_enc->rc_initial_buffer_occupancy = (my_avcodeccontext_enc->rc_buffer_size)*3/4;

my_avcodeccontext_enc->me_method = ME_EPZS;
my_avcodeccontext_enc->scenechange_threshold = 1000000000;//-sc_threshold 100000000
my_avcodeccontext_enc->mb_decision = FF_MB_DECISION_RD;//-mbd 2
my_avcodeccontext_enc->lmax = 340*FF_QP2LAMBDA;
my_avcodeccontext_enc->flags |= CODEC_FLAG_CBP_RD;//cbp
my_avcodeccontext_enc->flags |= CODEC_FLAG_TRELLIS_QUANT;//trell

Now I want to generate a MPEG2 IBP 60 Mbits file with a gop size of 10 and max_b_frame = 2. I tested many different settings but no one works as I expect. I always end up with a file that has I, B and P frames that have approximatively the same size. I know it depends of the content I want to encode and that I want is a I frame with a bigger size than the I frame encoded with the settings I used for I only encoding and B, P frame with a lower size.
So basicaly, how to get a high quality 60 Mbits/s IBP MPEG2 file ?

Please read below to see the last parameters I tried for IBP encoding :

//mybitrate has a value of 60 Mbits.

my_avcodeccontext_enc->bit_rate = mybitrate;//I want a 60 MBits/s file
my_avcodeccontext_enc->flags2 |= CODEC_FLAG2_STRICT_GOP;
my_avcodeccontext_enc->rc_max_rate = my_avcodeccontext_enc->bit_rate * 2;//To let the encoder making bigger I frames. my_avcodeccontext_enc->rc_min_rate = my_avcodeccontext_enc->bit_rate / 2;//To let the encoder making smaller B and P frames
my_avcodeccontext_enc->gop_size        = 10;
my_avcodeccontext_enc->max_b_frames    = 2;

my_avcodeccontext_enc->rc_buffer_size = ((40 * (my_avcodeccontext_enc->bit_rate/1000000))/1.15) * 8 * 1024;//((40 * my_avcodeccontext_enc->bit_rate)/1.15) / 1000000.0 * 8 * 1024; my_avcodeccontext_enc->rc_initial_buffer_occupancy = (my_avcodeccontext_enc->rc_buffer_size)*3/4;

my_avcodeccontext_enc->me_method = ME_EPZS;
my_avcodeccontext_enc->scenechange_threshold = 1000000000;//-sc_threshold 100000000
my_avcodeccontext_enc->mb_decision = FF_MB_DECISION_RD;//-mbd 2
my_avcodeccontext_enc->lmax = 340*FF_QP2LAMBDA;
my_avcodeccontext_enc->flags |= CODEC_FLAG_CBP_RD;//cbp
my_avcodeccontext_enc->flags |= CODEC_FLAG_TRELLIS_QUANT;//trell

Can anyone help me ?

Thanks in advance,

Tom Douce


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

Reply via email to