- c->codec_id = codec_id;
- c->codec_type = CODEC_TYPE_VIDEO;
-
- // put sample parameters
- c->bit_rate = mlt_properties_get_int( properties, "video_bit_rate" );
- c->width = mlt_properties_get_int( properties, "width" );
- c->height = mlt_properties_get_int( properties, "height" );
- c->frame_rate = mlt_properties_get_double( properties, "fps" );
- c->frame_rate_base = 1;
- c->gop_size = mlt_properties_get_int( properties, "gop_size" );
- c->max_b_frames = mlt_properties_get_int( properties, "max_b_frames" );
- c->mb_decision = mlt_properties_get_int( properties, "mb_decision" );
-
- // Some formats want stream headers to be seperate (hmm)
- if( !strcmp( oc->oformat->name, "mp4" ) ||
+ c->codec_id = codec_id;
+ c->codec_type = CODEC_TYPE_VIDEO;
+
+ // put sample parameters
+ c->bit_rate = mlt_properties_get_int( properties, "video_bit_rate" );
+ c->bit_rate_tolerance = mlt_properties_get_int( properties, "video_bit_rate_tolerance" );
+ c->width = mlt_properties_get_int( properties, "width" );
+ c->height = mlt_properties_get_int( properties, "height" );
+ c->frame_rate = mlt_properties_get_double( properties, "fps" );
+ c->frame_rate_base = mlt_properties_get_double( properties, "frame_rate_base" );
+ c->frame_rate_base = 1;
+ c->gop_size = mlt_properties_get_int( properties, "gop_size" );
+ c->max_b_frames = mlt_properties_get_int( properties, "max_b_frames" );
+ if ( c->max_b_frames )
+ {
+ c->b_frame_strategy = 0;
+ c->b_quant_factor = 2.0;
+ }
+
+ c->mb_decision = mlt_properties_get_int( properties, "mb_decision" );
+ c->sample_aspect_ratio = av_d2q( mlt_properties_get_double( properties, "aspect_ratio" ), 255 );
+
+
+ if ( mlt_properties_get_double( properties, "qscale" ) > 0 )
+ {
+ c->flags |= CODEC_FLAG_QSCALE;
+ st->quality = FF_QP2LAMBDA * mlt_properties_get_double( properties, "qscale" );
+ }
+
+ // Some formats want stream headers to be seperate (hmm)
+ if( !strcmp( oc->oformat->name, "mp4" ) ||