Mercurial > libavformat.hg
comparison flvdec.c @ 378:abd83fc30f0e libavformat
guess framerate
author | michael |
---|---|
date | Wed, 10 Mar 2004 03:45:14 +0000 |
parents | 20f644245408 |
children | c1f88671135b |
comparison
equal
deleted
inserted
replaced
377:d58f2852730e | 378:abd83fc30f0e |
---|---|
38 return 50; | 38 return 50; |
39 } | 39 } |
40 return 0; | 40 return 0; |
41 } | 41 } |
42 | 42 |
43 #define FRAME_RATE_UNKNOWN 31415 //yes i know its beatifull | |
44 | |
43 static int flv_read_header(AVFormatContext *s, | 45 static int flv_read_header(AVFormatContext *s, |
44 AVFormatParameters *ap) | 46 AVFormatParameters *ap) |
45 { | 47 { |
46 int offset, flags; | 48 int offset, flags; |
47 AVStream *st; | 49 AVStream *st; |
50 | |
51 s->ctx_flags |= AVFMTCTX_NOHEADER; //ok we have a header but theres no fps, codec type, sample_rate, ... | |
48 | 52 |
49 av_set_pts_info(s, 24, 1, 1000); /* 24 bit pts in ms */ | 53 av_set_pts_info(s, 24, 1, 1000); /* 24 bit pts in ms */ |
50 | 54 |
51 url_fskip(&s->pb, 4); | 55 url_fskip(&s->pb, 4); |
52 flags = get_byte(&s->pb); | 56 flags = get_byte(&s->pb); |
55 st = av_new_stream(s, 0); | 59 st = av_new_stream(s, 0); |
56 if (!st) | 60 if (!st) |
57 return AVERROR_NOMEM; | 61 return AVERROR_NOMEM; |
58 st->codec.codec_type = CODEC_TYPE_VIDEO; | 62 st->codec.codec_type = CODEC_TYPE_VIDEO; |
59 st->codec.codec_id = CODEC_ID_FLV1; | 63 st->codec.codec_id = CODEC_ID_FLV1; |
60 st->codec.frame_rate= ap->frame_rate; | 64 st->codec.frame_rate= FRAME_RATE_UNKNOWN; |
61 st->codec.frame_rate_base= ap->frame_rate_base; | 65 // st->codec.frame_rate= ap->frame_rate; |
66 // st->codec.frame_rate_base= ap->frame_rate_base; | |
62 } | 67 } |
63 | 68 |
64 if ((flags & 4)) { | 69 if ((flags & 4)) { |
65 st = av_new_stream(s, 1); | 70 st = av_new_stream(s, 1); |
66 if (!st) | 71 if (!st) |
116 if (st->id == ((type == 9) ? 0 : 1)) | 121 if (st->id == ((type == 9) ? 0 : 1)) |
117 goto found; | 122 goto found; |
118 } | 123 } |
119 goto skip; | 124 goto skip; |
120 found: | 125 found: |
121 if(type == 8){ | 126 if(type == 8 && st->codec.sample_rate == 0){ |
122 st->codec.channels = (flags&1)+1; | 127 st->codec.channels = (flags&1)+1; |
123 st->codec.sample_rate = (44100<<((flags>>2)&3))>>3; | 128 st->codec.sample_rate = (44100<<((flags>>2)&3))>>3; |
129 } | |
130 | |
131 //guess the frame rate | |
132 if(type==9 && st->codec.frame_rate == FRAME_RATE_UNKNOWN && pts){ | |
133 st->codec.frame_rate_base=1; | |
134 st->codec.frame_rate= (1000 + pts/2)/pts; | |
124 } | 135 } |
125 | 136 |
126 if (av_new_packet(pkt, size) < 0) | 137 if (av_new_packet(pkt, size) < 0) |
127 return -EIO; | 138 return -EIO; |
128 | 139 |