diff options
author | corp186 <chasedouglas@gmail.com> | 2009-05-23 10:09:16 +0400 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-05-23 10:09:16 +0400 |
commit | c69d224102acff478a85f678c0327604f10ec997 (patch) | |
tree | 35d99d227ca223b3c7327ee27be18bb1f5110677 /libavformat | |
parent | 9867a14f6ca324e918369af52d6dbcc97721e94e (diff) |
compute total bitrate more accurately, patch by corp186, chasedouglas at gmail dot com
Originally committed as revision 18909 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mpegtsenc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 0d6436eb18..04145d5818 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -426,6 +426,12 @@ static int mpegts_write_header(AVFormatContext *s) service->pcr_pid == 0x1fff) service->pcr_pid = ts_st->pid; total_bit_rate += st->codec->bit_rate; + /* PES header size */ + if (st->codec->codec_type == CODEC_TYPE_VIDEO || + st->codec->codec_type == CODEC_TYPE_SUBTITLE) + total_bit_rate += 25 * 8 / av_q2d(st->codec->time_base); + else + total_bit_rate += total_bit_rate * 25 / DEFAULT_PES_PAYLOAD_SIZE; } /* if no video stream, use the first stream as PCR */ @@ -458,7 +464,6 @@ static int mpegts_write_header(AVFormatContext *s) pat_pmt_size = url_ftell(s->pb) - pos; total_bit_rate += - total_bit_rate * 25 / DEFAULT_PES_PAYLOAD_SIZE + /* PES header size */ total_bit_rate * 4 / TS_PACKET_SIZE + /* TS header size */ SDT_RETRANS_TIME * 8 * sdt_size / 1000 + /* SDT size */ PAT_RETRANS_TIME * 8 * pat_pmt_size / 1000 + /* PAT+PMT size */ |