[FFmpeg-devel] MPEGTS stream auto-guessed before PMT is read
Stephen D'Angelo
SDAngelo
Thu Nov 25 17:16:34 CET 2010
On 11/19/2010 1:54:49 AM, Baptiste Coudurier wrote:
> To: FFmpeg development discussions and patches
> Subject: Re: [FFmpeg-devel] MPEGTS stream auto-guessed before PMT is
> read
>
> Hi,
>
> On 11/18/10 8:53 AM, Stephen D'Angelo wrote:
> > Hello,
> >
> > I have encountered transport streams where the AVStreams
> created are
> > not properly associated with the AVPrograms. I'm no expert on the
> > current mpegts.c code, but I believe it is happening
> because of the following:
> >
> > - The PMT for the stream's program is not read in
> mpegts_read_header
> > before auto_guess is turned on (line 1401)
> > - During av_find_stream_info, the pes stream is added to
> ts->pids in
> > handle_packet because auto_guess is true (line 1196)
> > - The PMT is read later and in pmt_cb the pes stream in found in
> > ts->pids, but pes->st has not been set yet, causing pmt_cb to return
> > (line 936)
> > - The AVStream for the pes stream is then added later in
> > mpegts_push_data (line 693), but it is not properly associated with
> > its AVProgram
> >
> > The following patch fixes the problem by creating an
> AVStream for the
> > pes stream if it doesn't have one, and then the subsequent call to
> > ff_program_add_stream_index properly associates the
> AVStream with the
> > AVProgram.
> >
> > Index: libavformat/mpegts.c
> > ===================================================================
> > --- libavformat/mpegts.c (revision 25762)
> > +++ libavformat/mpegts.c (working copy)
> > @@ -926,6 +926,8 @@
> > if (ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES) {
> > pes = ts->pids[pid]->u.pes_filter.opaque;
> > st = pes->st;
> > + if (!st)
> > + st = pes->st = av_new_stream(pes->stream,
> pes->pid);
> > } else {
> > if (ts->pids[pid]) mpegts_close_filter(ts,
> > ts->pids[pid]); //wrongly added sdt filter probably
> > pes = add_pes_stream(ts, pid, pcr_pid);
> >
> > Would it instead make more sense to "add_pid_to_pmt" before
> checking
> > that there is no AVStream (line 936) and "continue" if there is no
> > AVStream (line 937) so that all of the pes streams are
> associated with
> > the program and then after calling av_new_stream in
> mpegts_push_data,
> > call ff_program_add_stream_index to associate the AVStream with its
> > AVProgram? If it's done that way, the AVStream will not have the
> > proper language information that's added in pmt_cb.
>
> Thanks for the patch.
> I believe it is correct and that's the good approach. PMT is the
> reference.
>
> Can you please submit a file which shows this problem ?
>
> Thanks.
Sorry about that, this message flew past me. I'll blame Outlook's
message threading. This also explains your question as to whether I
read the mailing list.
I have uploaded a sample to
/MPlayer/incoming/mpegts_autoguess_before_pmt
Like the previous sample, I've noted that it is copyrighted material.
Thanks,
- Stephen
More information about the ffmpeg-devel
mailing list