# HG changeset patch # User arpi # Date 1020895874 0 # Node ID 5c3b0b165f3a84e86b68459de00dc9cae5b141bb # Parent 978e650f16f4cde35d9d0bab22e735c04452fada FPS autodetection, accept args: quality:fps diff -r 978e650f16f4 -r 5c3b0b165f3a libmpcodecs/vf_lavc.c --- a/libmpcodecs/vf_lavc.c Wed May 08 21:48:40 2002 +0000 +++ b/libmpcodecs/vf_lavc.c Wed May 08 22:11:14 2002 +0000 @@ -42,6 +42,22 @@ lavc_venc_context.width = width; lavc_venc_context.height = height; + + if(!lavc_venc_context.frame_rate){ + // guess FPS: + switch(height){ + case 240: + case 480: + lavc_venc_context.frame_rate=29.97*FRAME_RATE_BASE; // NTSC + break; + case 576: + case 288: + default: + lavc_venc_context.frame_rate=25*FRAME_RATE_BASE; // PAL + break; +// lavc_venc_context.frame_rate=vo_fps*FRAME_RATE_BASE; // same as src + } + } if(vf->priv->outbuf) free(vf->priv->outbuf); @@ -106,6 +122,9 @@ } static int open(vf_instance_t *vf, char* args){ + int p_quality=0; + float p_fps=0; + vf->config=config; vf->put_image=put_image; vf->query_format=query_format; @@ -125,12 +144,19 @@ } // TODO: parse args -> - lavc_venc_context.bit_rate = 8000000; - lavc_venc_context.frame_rate = 25 * FRAME_RATE_BASE; + if(args) sscanf(args, "%d:%f", &p_quality, &p_fps); + + if(p_quality<32){ + // fixed qscale + lavc_venc_context.flags = CODEC_FLAG_QSCALE; + lavc_venc_context.quality = (p_quality<1) ? 1 : p_quality; + } else { + // fixed bitrate (in kbits) + lavc_venc_context.bit_rate = 1000*p_quality; + } + lavc_venc_context.frame_rate = (p_fps<1.0) ? 0 : (p_fps * FRAME_RATE_BASE); lavc_venc_context.qmin= 1; lavc_venc_context.gop_size = 0; // I-only - lavc_venc_context.flags = CODEC_FLAG_QSCALE; - lavc_venc_context.quality = 1; return 1; }