Mercurial > libavformat.hg
comparison yuv4mpeg.c @ 85:25062c9b1f86 libavformat
per context frame_rate_base, this should finally fix frame_rate related av sync issues
author | michaelni |
---|---|
date | Wed, 12 Mar 2003 15:16:19 +0000 |
parents | a58a8a53eb46 |
children | d1290621cc6a |
comparison
equal
deleted
inserted
replaced
84:0068a6902911 | 85:25062c9b1f86 |
---|---|
24 | 24 |
25 static int yuv4_write_header(AVFormatContext *s) | 25 static int yuv4_write_header(AVFormatContext *s) |
26 { | 26 { |
27 AVStream *st; | 27 AVStream *st; |
28 int width, height; | 28 int width, height; |
29 int raten, rated, aspectn, aspectd, fps, fps1, n; | 29 int raten, rated, aspectn, aspectd, fps, fps1, n, gcd; |
30 char buf[Y4M_LINE_MAX+1]; | 30 char buf[Y4M_LINE_MAX+1]; |
31 | 31 |
32 if (s->nb_streams != 1) | 32 if (s->nb_streams != 1) |
33 return -EIO; | 33 return -EIO; |
34 | 34 |
35 st = s->streams[0]; | 35 st = s->streams[0]; |
36 width = st->codec.width; | 36 width = st->codec.width; |
37 height = st->codec.height; | 37 height = st->codec.height; |
38 | 38 |
39 #if 1 | |
40 //this is identical to the code below for exact fps | |
41 av_reduce(&raten, &rated, st->codec.frame_rate, st->codec.frame_rate_base, (1UL<<31)-1); | |
42 #else | |
39 fps = st->codec.frame_rate; | 43 fps = st->codec.frame_rate; |
40 fps1 = (((float)fps / FRAME_RATE_BASE) * 1000); | 44 fps1 = (((float)fps / st->codec.frame_rate_base) * 1000); |
41 | 45 |
42 /* Sorry about this messy code, but mpeg2enc is very picky about | 46 /* Sorry about this messy code, but mpeg2enc is very picky about |
43 * the framerates it accepts. */ | 47 * the framerates it accepts. */ |
44 switch(fps1) { | 48 switch(fps1) { |
45 case 23976: | 49 case 23976: |
73 case 60000: | 77 case 60000: |
74 raten = 60; | 78 raten = 60; |
75 rated = 1; | 79 rated = 1; |
76 break; | 80 break; |
77 default: | 81 default: |
78 raten = fps1; /* this setting should work, but often doesn't */ | 82 raten = st->codec.frame_rate; /* this setting should work, but often doesn't */ |
79 rated = 1000; | 83 rated = st->codec.frame_rate_base; |
84 gcd= av_gcd(raten, rated); | |
85 raten /= gcd; | |
86 rated /= gcd; | |
80 break; | 87 break; |
81 } | 88 } |
89 #endif | |
82 | 90 |
83 aspectn = 1; | 91 aspectn = 1; |
84 aspectd = 1; /* ffmpeg always uses a 1:1 aspect ratio */ | 92 aspectd = 1; /* ffmpeg always uses a 1:1 aspect ratio */ //FIXME not true anymore |
85 | 93 |
86 /* construct stream header, if this is the first frame */ | 94 /* construct stream header, if this is the first frame */ |
87 n = snprintf(buf, sizeof(buf), "%s W%d H%d F%d:%d I%s A%d:%d\n", | 95 n = snprintf(buf, sizeof(buf), "%s W%d H%d F%d:%d I%s A%d:%d\n", |
88 Y4M_MAGIC, | 96 Y4M_MAGIC, |
89 width, | 97 width, |