[Ffmpeg-devel] Real-time mpegts encoding and streaming

Måns Rullgård mans
Fri Mar 2 19:52:21 CET 2007


Luca Abeni <lucabe72 at email.it> writes:

> Hi all,
>
> On Thu, 2007-03-01 at 17:15 +0100, Luca Abeni wrote:
> [...]
>> I suspect you forgot the biggest problem: DTSs are never set... At 
>> least, last time I checked the PES header was filled with PTSs only. I 
>> do not think this was ok for a lot of clients. I'll double check tomorrow.
> The attached patch partly fixes the TS muxer, so that it at least sets
> the DTS for video PESs. There still are interleaving problems, but the
> produced TS is more correct than the one currently produced.
>
> Comments?
>
> @@ -541,7 +545,28 @@
>              if (st->codec->codec_type == CODEC_TYPE_SUBTITLE)
>                  val |= 0x04;
>              *q++ = val;
> -            if (pts != AV_NOPTS_VALUE) {
> +            if ((pts != AV_NOPTS_VALUE) && (dts != AV_NOPTS_VALUE)) {
> +                *q++ = 0xC0; /* PTS + DTS */
> +                *q++ = 0x0A; /* header len */
> +                val = (0x03 << 4) |
> +                    (((pts >> 30) & 0x07) << 1) | 1;
> +                *q++ = val;
> +                val = (((pts >> 15) & 0x7fff) << 1) | 1;
> +                *q++ = val >> 8;
> +                *q++ = val;
> +                val = (((pts) & 0x7fff) << 1) | 1;
> +                *q++ = val >> 8;
> +                *q++ = val;
> +                val = (0x01 << 4) |
> +                    (((dts >> 30) & 0x07) << 1) | 1;
> +                *q++ = val;
> +                val = (((dts >> 15) & 0x7fff) << 1) | 1;
> +                *q++ = val >> 8;
> +                *q++ = val;
> +                val = (((dts) & 0x7fff) << 1) | 1;
> +                *q++ = val >> 8;
> +                *q++ = val;
> +            } else if (pts != AV_NOPTS_VALUE) {
>                  *q++ = 0x80; /* PTS only */
>                  *q++ = 0x05; /* header len */
>                  val = (0x02 << 4) |

This duplicates the PTS writing code.

The rest looks OK.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list