[FFmpeg-devel] set pkt->pos in mpegts demuxer

Måns Rullgård mans
Fri Oct 24 20:30:55 CEST 2008


"Pascal Massimino" <pascal.massimino at gmail.com> writes:

> Hi everybody,
>
> On Thu, Oct 23, 2008 at 3:39 PM, M?ns Rullg?rd <mans at mansr.com> wrote:
>> "Pascal Massimino" <pascal.massimino at gmail.com> writes:
>>
>>> hi everybody,
>>>
>>> cf $title
>>>
>>> skal
>>>
>>> --- libavformat/mpegts.c      2008-10-23 15:08:01.940229000 -0700
>>> +++ libavformat/mpegts.c      2008-10-23 15:08:01.944225000 -0700
>>> @@ -915,6 +915,7 @@
>>>                      pkt->stream_index = pes->st->index;
>>>                      pkt->pts = pes->pts;
>>>                      pkt->dts = pes->dts;
>>> +                    pkt->pos = url_ftell(ts->stream->pb);
>>>                      /* reset pts values */
>>>                      pes->pts = AV_NOPTS_VALUE;
>>>                      pes->dts = AV_NOPTS_VALUE;
>>
>> That will be pointing to the next packet.
>
> oh! indeed. Let's (hopefully) do the right thing then (attached).
>
> skal
>
> --- mpegts.c	2008-10-24 09:54:21.606979000 -0700
> +++ mpegts.c.new	2008-10-24 09:50:19.595655000 -0700
> @@ -148,6 +148,7 @@
>      int pes_header_size;
>      int64_t pts, dts;
>      uint8_t header[MAX_PES_HEADER_SIZE];
> +    int64_t packet_pos;
>  };
>  
>  extern AVInputFormat mpegts_demuxer;
> @@ -823,6 +824,7 @@
>      if (is_start) {
>          pes->state = MPEGTS_HEADER;
>          pes->data_index = 0;
> +        pes->packet_pos = url_ftell(ts->stream->pb);
>      }
>      p = buf;
>      while (buf_size > 0) {
> @@ -915,6 +917,7 @@
>                      pkt->stream_index = pes->st->index;
>                      pkt->pts = pes->pts;
>                      pkt->dts = pes->dts;
> +                    pkt->pos = pes->packet_pos;
>                      /* reset pts values */
>                      pes->pts = AV_NOPTS_VALUE;
>                      pes->dts = AV_NOPTS_VALUE;

That's only a more complicated way of doing the same thing.

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




More information about the ffmpeg-devel mailing list