changeset 4951:a9842f362bbb libavformat

compute total bitrate more accurately, patch by corp186, chasedouglas at gmail dot com
author bcoudurier
date Sat, 23 May 2009 06:09:16 +0000
parents 3be97dd76d2c
children 0be83fd54e7a
files mpegtsenc.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mpegtsenc.c	Sat May 23 03:05:56 2009 +0000
+++ b/mpegtsenc.c	Sat May 23 06:09:16 2009 +0000
@@ -426,6 +426,12 @@
             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 @@
     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 */