summaryrefslogtreecommitdiffstats
path: root/libavformat/mpegtsenc.c
diff options
context:
space:
mode:
authorcorp186 <chasedouglas@gmail.com>2009-05-23 06:09:16 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-05-23 06:09:16 +0000
commitc69d224102acff478a85f678c0327604f10ec997 (patch)
tree35d99d227ca223b3c7327ee27be18bb1f5110677 /libavformat/mpegtsenc.c
parent9867a14f6ca324e918369af52d6dbcc97721e94e (diff)
downloadffmpeg-streaming-c69d224102acff478a85f678c0327604f10ec997.zip
ffmpeg-streaming-c69d224102acff478a85f678c0327604f10ec997.tar.gz
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/mpegtsenc.c')
-rw-r--r--libavformat/mpegtsenc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 0d6436e..04145d5 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 */
OpenPOWER on IntegriCloud