Commit 9de0be61 authored by Michael Niedermayer's avatar Michael Niedermayer

Do not force fps unless the user actually specified one.

fixes issue309

Originally committed as revision 11322 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent b4abe1d1
...@@ -115,7 +115,7 @@ static int frame_bottomBand = 0; ...@@ -115,7 +115,7 @@ static int frame_bottomBand = 0;
static int frame_leftBand = 0; static int frame_leftBand = 0;
static int frame_rightBand = 0; static int frame_rightBand = 0;
static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX}; static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};
static AVRational frame_rate = (AVRational) {25,1}; static AVRational frame_rate = (AVRational) {0,0};
static float video_qscale = 0; static float video_qscale = 0;
static int video_qdiff = 3; static int video_qdiff = 3;
static uint16_t *intra_matrix = NULL; static uint16_t *intra_matrix = NULL;
...@@ -2869,6 +2869,7 @@ static void new_video_stream(AVFormatContext *oc) ...@@ -2869,6 +2869,7 @@ static void new_video_stream(AVFormatContext *oc)
char *p; char *p;
int i; int i;
AVCodec *codec; AVCodec *codec;
AVRational fps= frame_rate.num ? frame_rate : (AVRational){25,1};
codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_VIDEO); codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_VIDEO);
if (video_codec_name) if (video_codec_name)
...@@ -2885,15 +2886,14 @@ static void new_video_stream(AVFormatContext *oc) ...@@ -2885,15 +2886,14 @@ static void new_video_stream(AVFormatContext *oc)
av_set_string(video_enc, opt_names[i], str); av_set_string(video_enc, opt_names[i], str);
} }
video_enc->time_base.den = frame_rate.num; video_enc->time_base.den = fps.num;
video_enc->time_base.num = frame_rate.den; video_enc->time_base.num = fps.den;
if(codec && codec->supported_framerates){ if(codec && codec->supported_framerates){
const AVRational *p= codec->supported_framerates; const AVRational *p= codec->supported_framerates;
AVRational req= (AVRational){frame_rate.num, frame_rate.den};
const AVRational *best=NULL; const AVRational *best=NULL;
AVRational best_error= (AVRational){INT_MAX, 1}; AVRational best_error= (AVRational){INT_MAX, 1};
for(; p->den!=0; p++){ for(; p->den!=0; p++){
AVRational error= av_sub_q(req, *p); AVRational error= av_sub_q(fps, *p);
if(error.num <0) error.num *= -1; if(error.num <0) error.num *= -1;
if(av_cmp_q(error, best_error) < 0){ if(av_cmp_q(error, best_error) < 0){
best_error= error; best_error= error;
......
...@@ -85,7 +85,10 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -85,7 +85,10 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
av_set_pts_info(st, 64, 1, st->codec->sample_rate); av_set_pts_info(st, 64, 1, st->codec->sample_rate);
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); if(ap->time_base.num)
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
else
av_set_pts_info(st, 64, 1, 25);
st->codec->width = ap->width; st->codec->width = ap->width;
st->codec->height = ap->height; st->codec->height = ap->height;
st->codec->pix_fmt = ap->pix_fmt; st->codec->pix_fmt = ap->pix_fmt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment