diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 7138009716..48df4386da 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -428,10 +428,18 @@ static int mpegts_write_header(AVFormatContext *s) 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; + st->codec->codec_type == CODEC_TYPE_SUBTITLE) { + /* 1 PES per frame + * 19 bytes of PES header + * on average a half TS-packet (184/2) of padding-overhead every PES */ + total_bit_rate += (19 + 184/2)*8 / av_q2d(st->codec->time_base); + } else { + /* 1 PES per DEFAULT_PES_PAYLOAD_SIZE bytes of audio data + * 14 bytes of PES header + * on average a half TS-packet (184/2) of padding-overhead every PES */ + total_bit_rate += (14 + 184/2) * + st->codec->bit_rate / DEFAULT_PES_PAYLOAD_SIZE; + } } /* if no video stream, use the first stream as PCR */ diff --git a/tests/lavf.regression.ref b/tests/lavf.regression.ref index a00aaad919..8b0b1555c9 100644 --- a/tests/lavf.regression.ref +++ b/tests/lavf.regression.ref @@ -15,8 +15,8 @@ e36a005ecca9add8bda6e0655d03716f *./tests/data/b-lavf.mpg b3174e2db508564c1cce0b5e3c1bc1bd *./tests/data/b-lavf.mxf_d10 5330989 ./tests/data/b-lavf.mxf_d10 ./tests/data/b-lavf.mxf_d10 CRC=0xc3f4f92e -34c47c149402e602c87455c4276ea0a5 *./tests/data/b-lavf.ts -438792 ./tests/data/b-lavf.ts +5db794c5f69f934bbcdbe32de1df9f3a *./tests/data/b-lavf.ts +436160 ./tests/data/b-lavf.ts ./tests/data/b-lavf.ts CRC=0x133216c1 62c5aeb636fc82cf6ba6277d36e42cb5 *./tests/data/b-lavf.swf 329479 ./tests/data/b-lavf.swf