aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/yuv4mpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-03-12 15:16:19 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-03-12 15:16:19 +0000
commit14bea432f16d7c66f9099e427819028b6b4c3bdc (patch)
treec52726ce14a0265337b9deebd2214e2552d284b0 /libavformat/yuv4mpeg.c
parent586bc7553ca90dee507afd950de64bbd2c6a80b5 (diff)
downloadffmpeg-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/yuv4mpeg.c')
-rw-r--r--libavformat/yuv4mpeg.c20
1 files changed, 14 insertions, 6 deletions
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",