diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-03-12 15:16:19 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-03-12 15:16:19 +0000 |
commit | 14bea432f16d7c66f9099e427819028b6b4c3bdc (patch) | |
tree | c52726ce14a0265337b9deebd2214e2552d284b0 /libavformat | |
parent | 586bc7553ca90dee507afd950de64bbd2c6a80b5 (diff) | |
download | ffmpeg-14bea432f16d7c66f9099e427819028b6b4c3bdc.tar.gz |
per context frame_rate_base, this should finally fix frame_rate related av sync issues
Originally committed as revision 1666 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/asf.c | 3 | ||||
-rw-r--r-- | libavformat/avformat.h | 4 | ||||
-rw-r--r-- | libavformat/avidec.c | 16 | ||||
-rw-r--r-- | libavformat/avienc.c | 10 | ||||
-rw-r--r-- | libavformat/dv1394.c | 3 | ||||
-rw-r--r-- | libavformat/ffm.c | 15 | ||||
-rw-r--r-- | libavformat/gif.c | 6 | ||||
-rw-r--r-- | libavformat/gifdec.c | 3 | ||||
-rw-r--r-- | libavformat/grab.c | 14 | ||||
-rw-r--r-- | libavformat/img.c | 13 | ||||
-rw-r--r-- | libavformat/mov.c | 8 | ||||
-rw-r--r-- | libavformat/raw.c | 9 | ||||
-rw-r--r-- | libavformat/rm.c | 5 | ||||
-rw-r--r-- | libavformat/rtp.c | 6 | ||||
-rw-r--r-- | libavformat/swf.c | 12 | ||||
-rw-r--r-- | libavformat/utils.c | 23 | ||||
-rw-r--r-- | libavformat/yuv4mpeg.c | 20 |
17 files changed, 92 insertions, 78 deletions
diff --git a/libavformat/asf.c b/libavformat/asf.c index b9cd71e432..c2a3318d87 100644 --- a/libavformat/asf.c +++ b/libavformat/asf.c @@ -621,8 +621,7 @@ static int asf_write_packet(AVFormatContext *s, int stream_index, duration = (codec->frame_number * codec->frame_size * int64_t_C(10000000)) / codec->sample_rate; } else { - duration = codec->frame_number * - ((int64_t_C(10000000) * FRAME_RATE_BASE) / codec->frame_rate); + duration = av_rescale(codec->frame_number * codec->frame_rate_base, 10000000, codec->frame_rate); } if (duration > asf->duration) asf->duration = duration; diff --git a/libavformat/avformat.h b/libavformat/avformat.h index f9d435a9b2..287bb80b0f 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -77,6 +77,7 @@ typedef struct AVProbeData { typedef struct AVFormatParameters { int frame_rate; + int frame_rate_base; int sample_rate; int channels; int width; @@ -159,6 +160,7 @@ typedef struct AVStream { int id; /* format specific stream id */ AVCodecContext codec; /* codec context */ int r_frame_rate; /* real frame rate of the stream */ + int r_frame_rate_base;/* real frame rate base of the stream */ uint64_t time_length; /* real length of the stream in miliseconds */ void *priv_data; /* internal data used in av_find_stream_info() */ @@ -332,8 +334,6 @@ extern AVOutputFormat yuv4mpegpipe_oformat; #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) -int av_gcd(int a, int b); - void av_register_input_format(AVInputFormat *format); void av_register_output_format(AVOutputFormat *format); AVOutputFormat *guess_stream_format(const char *short_name, diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 6d23f07079..bec8c77040 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -133,12 +133,16 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) scale= get_le32(pb); /* scale */ rate= get_le32(pb); /* rate */ - if(scale && rate) - st->codec.frame_rate= (rate * (uint64_t)FRAME_RATE_BASE + scale/2) / scale; - else if(frame_period) - st->codec.frame_rate = (1000000LL * FRAME_RATE_BASE + frame_period/2) / frame_period; - else - st->codec.frame_rate = 25 * FRAME_RATE_BASE; + if(scale && rate){ + st->codec.frame_rate = rate; + st->codec.frame_rate_base= scale; + }else if(frame_period){ + st->codec.frame_rate = 1000000; + st->codec.frame_rate_base= frame_period; + }else{ + st->codec.frame_rate = 25; + st->codec.frame_rate_base = 1; + } url_fskip(pb, size - 7 * 4); break; diff --git a/libavformat/avienc.c b/libavformat/avienc.c index 2f36801bcb..f885d657a9 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -218,7 +218,7 @@ static int avi_write_header(AVFormatContext *s) nb_frames = 0; if(video_enc){ - put_le32(pb, (uint32_t)(int64_t_C(1000000) * FRAME_RATE_BASE / video_enc->frame_rate)); + put_le32(pb, (uint32_t)(int64_t_C(1000000) * video_enc->frame_rate_base / video_enc->frame_rate)); } else { put_le32(pb, 0); } @@ -244,8 +244,6 @@ static int avi_write_header(AVFormatContext *s) /* stream list */ for(i=0;i<n;i++) { - int gcd; - list2 = start_tag(pb, "LIST"); put_tag(pb, "strl"); @@ -262,10 +260,8 @@ static int avi_write_header(AVFormatContext *s) put_le16(pb, 0); /* language */ put_le32(pb, 0); /* initial frame */ - gcd= av_gcd(stream->frame_rate, FRAME_RATE_BASE); - - put_le32(pb, FRAME_RATE_BASE / gcd); /* scale */ - put_le32(pb, stream->frame_rate / gcd); /* rate */ + put_le32(pb, stream->frame_rate_base); /* scale */ + put_le32(pb, stream->frame_rate); /* rate */ put_le32(pb, 0); /* start */ avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */ diff --git a/libavformat/dv1394.c b/libavformat/dv1394.c index 7048c342c8..31d583c265 100644 --- a/libavformat/dv1394.c +++ b/libavformat/dv1394.c @@ -138,7 +138,8 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap vst->codec.codec_id = CODEC_ID_DVVIDEO; vst->codec.width = dv->width; vst->codec.height = dv->height; - vst->codec.frame_rate = dv->frame_rate * FRAME_RATE_BASE; + vst->codec.frame_rate = dv->frame_rate; + vst->codec.frame_rate_base = 1; vst->codec.bit_rate = 25000000; /* Consumer DV is 25Mbps */ ast->codec.codec_type = CODEC_TYPE_AUDIO; diff --git a/libavformat/ffm.c b/libavformat/ffm.c index f2615673af..de2ea6bef1 100644 --- a/libavformat/ffm.c +++ b/libavformat/ffm.c @@ -140,8 +140,6 @@ static int ffm_write_header(AVFormatContext *s) /* list of streams */ for(i=0;i<s->nb_streams;i++) { - int gcd; - st = s->streams[i]; fst = av_mallocz(sizeof(FFMStream)); if (!fst) @@ -158,9 +156,8 @@ static int ffm_write_header(AVFormatContext *s) /* specific info */ switch(codec->codec_type) { case CODEC_TYPE_VIDEO: - gcd= av_gcd(FRAME_RATE_BASE, codec->frame_rate); - put_be32(pb, FRAME_RATE_BASE / gcd); - put_be32(pb, codec->frame_rate / gcd); + put_be32(pb, codec->frame_rate_base); + put_be32(pb, codec->frame_rate); put_be16(pb, codec->width); put_be16(pb, codec->height); put_be16(pb, codec->gop_size); @@ -229,7 +226,7 @@ static int ffm_write_packet(AVFormatContext *s, int stream_index, if (st->codec.codec_type == CODEC_TYPE_AUDIO) { duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0); } else { - duration = (1000000.0 * FRAME_RATE_BASE / (float)st->codec.frame_rate); + duration = (1000000.0 * st->codec.frame_rate_base / (float)st->codec.frame_rate); } pts = fst->pts; @@ -394,7 +391,6 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) /* read each stream */ for(i=0;i<s->nb_streams;i++) { char rc_eq_buf[128]; - int rate, scale; st = av_mallocz(sizeof(AVStream)); if (!st) @@ -416,9 +412,8 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) /* specific info */ switch(codec->codec_type) { case CODEC_TYPE_VIDEO: - scale= get_be32(pb); - rate= get_be32(pb); - codec->frame_rate = (rate * (int64_t)FRAME_RATE_BASE) / scale; + codec->frame_rate_base = get_be32(pb); + codec->frame_rate = get_be32(pb); codec->width = get_be16(pb); codec->height = get_be16(pb); codec->gop_size = get_be16(pb); diff --git a/libavformat/gif.c b/libavformat/gif.c index 47b32eff79..1df8827a33 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -296,7 +296,7 @@ static int gif_write_header(AVFormatContext *s) GIFContext *gif = s->priv_data; ByteIOContext *pb = &s->pb; AVCodecContext *enc, *video_enc; - int i, width, height, rate; + int i, width, height/*, rate*/; /* XXX: do we reject audio streams or just ignore them ? if(s->nb_streams > 1) @@ -318,7 +318,7 @@ static int gif_write_header(AVFormatContext *s) } else { width = video_enc->width; height = video_enc->height; - rate = video_enc->frame_rate; +// rate = video_enc->frame_rate; } /* XXX: is it allowed ? seems to work so far... */ @@ -351,7 +351,7 @@ static int gif_write_video(AVFormatContext *s, /* XXX: should use delay, in order to be more accurate */ /* instead of using the same rounded value each time */ /* XXX: don't even remember if I really use it for now */ - jiffies = (70*FRAME_RATE_BASE/enc->frame_rate) - 1; + jiffies = (70*enc->frame_rate_base/enc->frame_rate) - 1; put_le16(pb, jiffies); diff --git a/libavformat/gifdec.c b/libavformat/gifdec.c index b827845fe9..0ee59bc5f3 100644 --- a/libavformat/gifdec.c +++ b/libavformat/gifdec.c @@ -535,7 +535,8 @@ static int gif_read_header(AVFormatContext * s1, st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec.codec_id = CODEC_ID_RAWVIDEO; - st->codec.frame_rate = 5 * FRAME_RATE_BASE; + st->codec.frame_rate = 5; + st->codec.frame_rate_base = 1; /* XXX: check if screen size is always valid */ st->codec.width = s->screen_width; st->codec.height = s->screen_height; diff --git a/libavformat/grab.c b/libavformat/grab.c index 7b8a1bcca9..3a99704520 100644 --- a/libavformat/grab.c +++ b/libavformat/grab.c @@ -31,6 +31,7 @@ typedef struct { int use_mmap; int width, height; int frame_rate; + int frame_rate_base; int64_t time_frame; int frame_size; struct video_capability video_cap; @@ -59,7 +60,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) AVStream *st; int width, height; int video_fd, frame_size; - int ret, frame_rate; + int ret, frame_rate, frame_rate_base; int desired_palette; struct video_audio audio; const char *video_device; @@ -69,7 +70,8 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) width = ap->width; height = ap->height; - frame_rate = ap->frame_rate; + frame_rate = ap->frame_rate; + frame_rate_base = ap->frame_rate_base; st = av_new_stream(s1, 0); if (!st) @@ -77,7 +79,8 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) s->width = width; s->height = height; - s->frame_rate = frame_rate; + s->frame_rate = frame_rate; + s->frame_rate_base = frame_rate_base; video_device = ap->device; if (!video_device) @@ -240,7 +243,8 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) st->codec.codec_id = CODEC_ID_RAWVIDEO; st->codec.width = width; st->codec.height = height; - st->codec.frame_rate = frame_rate; + st->codec.frame_rate = frame_rate; + st->codec.frame_rate_base = frame_rate_base; av_set_pts_info(s1, 48, 1, 1000000); /* 48 bits pts in us */ @@ -283,7 +287,7 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt) VideoData *s = s1->priv_data; int64_t curtime, delay; struct timespec ts; - int64_t per_frame = (int64_t_C(1000000) * FRAME_RATE_BASE) / s->frame_rate; + int64_t per_frame = (int64_t_C(1000000) * s->frame_rate_base) / s->frame_rate; /* Calculate the time of the next frame */ s->time_frame += per_frame; diff --git a/libavformat/img.c b/libavformat/img.c index 178cee8911..36e501f109 100644 --- a/libavformat/img.c +++ b/libavformat/img.c @@ -124,10 +124,13 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) st->codec.pix_fmt = s->pix_fmt; s->img_size = avpicture_get_size(s->pix_fmt, s->width, s->height); - if (!ap || !ap->frame_rate) - st->codec.frame_rate = 25 * FRAME_RATE_BASE; - else - st->codec.frame_rate = ap->frame_rate; + if (!ap || !ap->frame_rate){ + st->codec.frame_rate = 25; + st->codec.frame_rate_base = 1; + }else{ + st->codec.frame_rate = ap->frame_rate; + st->codec.frame_rate_base = ap->frame_rate_base; + } return 0; fail1: @@ -182,7 +185,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) av_free_packet(pkt); return -EIO; /* signal EOF */ } else { - pkt->pts = ((int64_t)s->img_number * s1->pts_den * FRAME_RATE_BASE) / (s1->streams[0]->codec.frame_rate * s1->pts_num); + pkt->pts = av_rescale((int64_t)s->img_number * s1->streams[0]->codec.frame_rate_base, s1->pts_den, s1->streams[0]->codec.frame_rate) / s1->pts_num; s->img_number++; return 0; } diff --git a/libavformat/mov.c b/libavformat/mov.c index 0e43c54c4f..fe99673fa3 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -686,7 +686,8 @@ static int parse_stsd(const MOVParseTableEntry *parse_table, ByteIOContext *pb, get_be16(pb); /* depth */ get_be16(pb); /* colortable id */ - st->codec.frame_rate = 25 * FRAME_RATE_BASE; + st->codec.frame_rate = 25; + st->codec.frame_rate_base = 1; size -= (16+8*4+2+32+2*2); while (size >= 8) { @@ -932,9 +933,8 @@ printf("track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries); sample_duration = get_be32(pb); if (!i && st->codec.codec_type==CODEC_TYPE_VIDEO) { - st->codec.frame_rate = FRAME_RATE_BASE * c->streams[c->total_streams]->time_scale; - if (sample_duration) - st->codec.frame_rate /= sample_duration; + st->codec.frame_rate_base = sample_duration ? sample_duration : 1; + st->codec.frame_rate = c->streams[c->total_streams]->time_scale; #ifdef DEBUG printf("VIDEO FRAME RATE= %i (sd= %i)\n", st->codec.frame_rate, sample_duration); #endif diff --git a/libavformat/raw.c b/libavformat/raw.c index f32f5eb599..a1dcf871c4 100644 --- a/libavformat/raw.c +++ b/libavformat/raw.c @@ -61,7 +61,8 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec.channels = ap->channels; break; case CODEC_TYPE_VIDEO: - st->codec.frame_rate = ap->frame_rate; + st->codec.frame_rate = ap->frame_rate; + st->codec.frame_rate_base = ap->frame_rate_base; st->codec.width = ap->width; st->codec.height = ap->height; break; @@ -151,9 +152,11 @@ static int video_read_header(AVFormatContext *s, /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/ if (st->codec.codec_id == CODEC_ID_MJPEG || st->codec.codec_id == CODEC_ID_MPEG4) { if (ap) { - st->codec.frame_rate = ap->frame_rate; + st->codec.frame_rate = ap->frame_rate; + st->codec.frame_rate_base = ap->frame_rate_base; } else { - st->codec.frame_rate = 25 * FRAME_RATE_BASE; + st->codec.frame_rate = 25; + st->codec.frame_rate_base = 1; } } return 0; diff --git a/libavformat/rm.c b/libavformat/rm.c index f5ae3a3f33..47b510b323 100644 --- a/libavformat/rm.c +++ b/libavformat/rm.c @@ -306,7 +306,7 @@ static int rm_write_header(AVFormatContext *s) break; case CODEC_TYPE_VIDEO: rm->video_stream = stream; - stream->frame_rate = (float)codec->frame_rate / (float)FRAME_RATE_BASE; + stream->frame_rate = (float)codec->frame_rate / (float)codec->frame_rate_base; /* XXX: dummy values */ stream->packet_max_size = 4096; stream->nb_packets = 0; @@ -582,7 +582,8 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail1; st->codec.width = get_be16(pb); st->codec.height = get_be16(pb); - st->codec.frame_rate = get_be16(pb) * FRAME_RATE_BASE; + st->codec.frame_rate_base= 1; + st->codec.frame_rate = get_be16(pb) * st->codec.frame_rate_base; st->codec.codec_type = CODEC_TYPE_VIDEO; get_be32(pb); get_be16(pb); diff --git a/libavformat/rtp.c b/libavformat/rtp.c index 87d28a3f77..45372b4ed6 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -560,9 +560,8 @@ static void rtp_send_mpegvideo(AVFormatContext *s1, q += len; /* 90 KHz time stamp */ - /* XXX: overflow */ s->timestamp = s->base_timestamp + - (s->cur_timestamp * 90000LL * FRAME_RATE_BASE) / st->codec.frame_rate; + av_rescale((int64_t)s->cur_timestamp * st->codec.frame_rate_base, 90000, st->codec.frame_rate); rtp_send_data(s1, s->buf, q - s->buf); buf1 += len; @@ -586,9 +585,8 @@ static void rtp_send_raw(AVFormatContext *s1, len = size; /* 90 KHz time stamp */ - /* XXX: overflow */ s->timestamp = s->base_timestamp + - (s->cur_timestamp * 90000LL * FRAME_RATE_BASE) / st->codec.frame_rate; + av_rescale((int64_t)s->cur_timestamp * st->codec.frame_rate_base, 90000, st->codec.frame_rate); rtp_send_data(s1, buf1, len); buf1 += len; diff --git a/libavformat/swf.c b/libavformat/swf.c index 9b86b58bee..60d931e2bf 100644 --- a/libavformat/swf.c +++ b/libavformat/swf.c @@ -194,7 +194,7 @@ static int swf_write_header(AVFormatContext *s) AVCodecContext *enc, *audio_enc, *video_enc; PutBitContext p; uint8_t buf1[256]; - int i, width, height, rate; + int i, width, height, rate, rate_base; swf = av_malloc(sizeof(SWFContext)); if (!swf) @@ -215,11 +215,13 @@ static int swf_write_header(AVFormatContext *s) /* currenty, cannot work correctly if audio only */ width = 320; height = 200; - rate = 10 * FRAME_RATE_BASE; + rate = 10; + rate_base= 1; } else { width = video_enc->width; height = video_enc->height; rate = video_enc->frame_rate; + rate_base = video_enc->frame_rate_base; } put_tag(pb, "FWS"); @@ -228,9 +230,9 @@ static int swf_write_header(AVFormatContext *s) (will be patched if not streamed) */ put_swf_rect(pb, 0, width, 0, height); - put_le16(pb, (rate * 256) / FRAME_RATE_BASE); /* frame rate */ + put_le16(pb, (rate * 256) / rate_base); /* frame rate */ swf->duration_pos = url_ftell(pb); - put_le16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / FRAME_RATE_BASE)); /* frame count */ + put_le16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */ /* define a shape with the jpeg inside */ @@ -305,7 +307,7 @@ static int swf_write_header(AVFormatContext *s) put_swf_tag(s, TAG_STREAMHEAD); put_byte(&s->pb, 0); put_byte(&s->pb, v); - put_le16(&s->pb, (audio_enc->sample_rate * FRAME_RATE_BASE) / rate); /* avg samples per frame */ + put_le16(&s->pb, (audio_enc->sample_rate * rate_base) / rate); /* avg samples per frame */ put_swf_end_tag(s); diff --git a/libavformat/utils.c b/libavformat/utils.c index 5642894ec9..1c1c406606 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -614,10 +614,12 @@ int av_find_stream_info(AVFormatContext *ic) #endif /* stop after 40 frames */ if (st->codec_info_nb_real_frames >= 40) { - st->r_frame_rate = (st->codec.frame_rate * - st->codec_info_nb_real_frames) / - (st->codec_info_nb_real_frames + - (st->codec_info_nb_repeat_frames >> 1)); + av_reduce( + &st->r_frame_rate, + &st->r_frame_rate_base, + (int64_t)st->codec.frame_rate * st->codec_info_nb_real_frames, + st->codec_info_nb_real_frames + (st->codec_info_nb_repeat_frames >> 1), + 1<<30); goto close_codec; } } else { @@ -645,8 +647,10 @@ int av_find_stream_info(AVFormatContext *ic) for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; if (st->codec.codec_type == CODEC_TYPE_VIDEO) { - if (!st->r_frame_rate) - st->r_frame_rate = st->codec.frame_rate; + if (!st->r_frame_rate){ + st->r_frame_rate = st->codec.frame_rate; + st->r_frame_rate_base = st->codec.frame_rate_base; + } } } @@ -820,7 +824,7 @@ int av_write_frame(AVFormatContext *s, int stream_index, const uint8_t *buf, break; case CODEC_TYPE_VIDEO: av_frac_add(&st->pts, - (int64_t)s->pts_den * FRAME_RATE_BASE); + (int64_t)s->pts_den * st->codec.frame_rate_base); break; default: break; @@ -1316,11 +1320,6 @@ void av_frac_add(AVFrac *f, int64_t incr) f->num = num; } -int av_gcd(int a, int b){ - if(b) return av_gcd(b, a%b); - else return a; -} - /** * register a new image format * @param img_fmt Image format descriptor diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index 1659ca7885..2cdaf9b097 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -26,7 +26,7 @@ static int yuv4_write_header(AVFormatContext *s) { AVStream *st; int width, height; - int raten, rated, aspectn, aspectd, fps, fps1, n; + int raten, rated, aspectn, aspectd, fps, fps1, n, gcd; char buf[Y4M_LINE_MAX+1]; if (s->nb_streams != 1) @@ -35,9 +35,13 @@ static int yuv4_write_header(AVFormatContext *s) st = s->streams[0]; width = st->codec.width; height = st->codec.height; - + +#if 1 + //this is identical to the code below for exact fps + av_reduce(&raten, &rated, st->codec.frame_rate, st->codec.frame_rate_base, (1UL<<31)-1); +#else fps = st->codec.frame_rate; - fps1 = (((float)fps / FRAME_RATE_BASE) * 1000); + fps1 = (((float)fps / st->codec.frame_rate_base) * 1000); /* Sorry about this messy code, but mpeg2enc is very picky about * the framerates it accepts. */ @@ -75,13 +79,17 @@ static int yuv4_write_header(AVFormatContext *s) rated = 1; break; default: - raten = fps1; /* this setting should work, but often doesn't */ - rated = 1000; + raten = st->codec.frame_rate; /* this setting should work, but often doesn't */ + rated = st->codec.frame_rate_base; + gcd= av_gcd(raten, rated); + raten /= gcd; + rated /= gcd; break; } +#endif aspectn = 1; - aspectd = 1; /* ffmpeg always uses a 1:1 aspect ratio */ + aspectd = 1; /* ffmpeg always uses a 1:1 aspect ratio */ //FIXME not true anymore /* construct stream header, if this is the first frame */ n = snprintf(buf, sizeof(buf), "%s W%d H%d F%d:%d I%s A%d:%d\n", |