[FFmpeg-devel] [PATCH] Fix output rate of mpegts CBR muxer

Dan Dennedy dan
Thu Apr 22 05:35:14 CEST 2010


Baptiste,

On Wed, Apr 21, 2010 at 12:28 AM, Dan Dennedy <dan at dennedy.org> wrote:
> Hi,
> Currently, the mpegts muxer outputs a higher rate than requested using
> -muxrate due to the cur_pcr accumulating division truncation errors.
> For a 10 mbps stream, I see about 172 kbps higher than I requested.
> This fixes it by simply counting packets and then taking the division
> only when PCR is actually needed.

Please hold off on this patch. I made an error; see below. Also, my
ASI card and IRD does not like about this change indicating something.

> Index: libavformat/mpegtsenc.c
> ===================================================================
> --- libavformat/mpegtsenc.c ? ? (revision 22926)
> +++ libavformat/mpegtsenc.c ? ? (working copy)
> @@ -641,7 +643,8 @@
> ? ? ? ? if (write_pcr) {
> ? ? ? ? ? ? // add 11, pcr references the last byte of program clock
> reference base
> ? ? ? ? ? ? if (ts->mux_rate > 1)
> - ? ? ? ? ? ? ? ?pcr = ts->cur_pcr + (4+7)*8*90000LL / ts->mux_rate;
> + ? ? ? ? ? ? ? ?pcr = ts->pcr_delay + ((4+7) + ts->cur_pcr *
> + ? ? ? ? ? ? ? ? ? ? ?TS_PACKET_SIZE *8*90000LL) / ts->mux_rate;

There are missing parenthesis around  "(4+7) + ts->cur_pcr *?TS_PACKET_SIZE".

-- 
+-DRD-+



More information about the ffmpeg-devel mailing list