Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Dev

[PATCH] better avi seek support

 

 

MythTV dev RSS feed   Index | Next | Previous | View Threaded


mark at dclabs

May 3, 2005, 4:58 AM

Post #1 of 16 (2081 views)
Permalink
[PATCH] better avi seek support

I have implemented a patch that allows avis to be played and seeked correctly. it shows correct length too!
I know its a bit of a nasty hack.
The reasons for doing it this way is to minimise the impact on libavformat which Isaac has stressed.
Thus avidec.c has 1 new function and is thus easy to merge.
The new function is the same as avi_read_seek except without the url_fseek.
It is needed to sync the audio and video stream timestamps otherwise they diverge uncontrollably.
It is only activated if there is an index in the avi file.
The structures in avidec are partially reproduced in avformatdecoder.cpp to allow scanning of the index table.
This has been annoying me for a while now and have finally done something about it.
note that I use myth to play my avi's instead of mplayer or xine due to timestretch and thus it was higher on my priority list.
feedback welcome.
cheers
mark
Attachments: mythtv_aviseek1.patch.zip (3.29 KB)


john at BlueSkyTours

May 4, 2005, 7:14 AM

Post #2 of 16 (2057 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

Mark Spieth wrote:

> I have implemented a patch that allows avis to be played and seeked
> correctly. it shows correct length too!
> I know its a bit of a nasty hack.
> The reasons for doing it this way is to minimise the impact on
> libavformat which Isaac has stressed.
> Thus avidec.c has 1 new function and is thus easy to merge.
> The new function is the same as avi_read_seek except without the
> url_fseek.
> It is needed to sync the audio and video stream timestamps otherwise
> they diverge uncontrollably.
> It is only activated if there is an index in the avi file.
> The structures in avidec are partially reproduced in
> avformatdecoder.cpp to allow scanning of the index table.
> This has been annoying me for a while now and have finally done
> something about it.
> note that I use myth to play my avi's instead of mplayer or xine due
> to timestretch and thus it was higher on my priority list.
> feedback welcome.
> cheers
> mark


I have several videos I have tried to import into Myth in the past.
Doing a "mythcommflag --rebuild" has always been ineffectual.

I am at home waiting for the the "cable guy" to show up, and decided to
see if this patch solves the problem. It does!

After a jump to a new location in the file, the video is corrupt for a
few seconds, but then it clears up and looks fine. Small price to pay
to actually be able import these files into the main Myth system.

Thank you,

John

_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


jdonavan at jdonavan

May 4, 2005, 10:52 AM

Post #3 of 16 (2045 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

John Patrick Poet wrote:

> Mark Spieth wrote:
>
>> I have implemented a patch that allows avis to be played and seeked
>> correctly. it shows correct length too!
>> I know its a bit of a nasty hack.
>> The reasons for doing it this way is to minimise the impact on
>> libavformat which Isaac has stressed.
>> Thus avidec.c has 1 new function and is thus easy to merge.
>> The new function is the same as avi_read_seek except without the
>> url_fseek.
>> It is needed to sync the audio and video stream timestamps otherwise
>> they diverge uncontrollably.
>> It is only activated if there is an index in the avi file.
>> The structures in avidec are partially reproduced in
>> avformatdecoder.cpp to allow scanning of the index table.
>> This has been annoying me for a while now and have finally done
>> something about it.
>> note that I use myth to play my avi's instead of mplayer or xine due
>> to timestretch and thus it was higher on my priority list.
>> feedback welcome.
>> cheers
>> mark
>
>
>
> I have several videos I have tried to import into Myth in the past.
> Doing a "mythcommflag --rebuild" has always been ineffectual.


That's because the command is "mythcommflag --video"
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


john at BlueSkyTours

May 4, 2005, 12:41 PM

Post #4 of 16 (2051 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

On Wed, 4 May 2005, J. Donavan Stanley wrote:

> John Patrick Poet wrote:
>
> > Mark Spieth wrote:
> >
> >> I have implemented a patch that allows avis to be played and seeked
> >> correctly. it shows correct length too!
> >> I know its a bit of a nasty hack.
> >> The reasons for doing it this way is to minimise the impact on
> >> libavformat which Isaac has stressed.
> >> Thus avidec.c has 1 new function and is thus easy to merge.
> >> The new function is the same as avi_read_seek except without the
> >> url_fseek.
> >> It is needed to sync the audio and video stream timestamps otherwise
> >> they diverge uncontrollably.
> >> It is only activated if there is an index in the avi file.
> >> The structures in avidec are partially reproduced in
> >> avformatdecoder.cpp to allow scanning of the index table.
> >> This has been annoying me for a while now and have finally done
> >> something about it.
> >> note that I use myth to play my avi's instead of mplayer or xine due
> >> to timestretch and thus it was higher on my priority list.
> >> feedback welcome.
> >> cheers
> >> mark
> >
> >
> >
> > I have several videos I have tried to import into Myth in the past.
> > Doing a "mythcommflag --rebuild" has always been ineffectual.
>
>
> That's because the command is "mythcommflag --video"


Aah. Okay, for some reason I though that had to do with mythvideo instead
of mythtv. I will give that a try.

Thanks,

John


ijr at case

May 4, 2005, 12:51 PM

Post #5 of 16 (2038 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

On Tuesday 03 May 2005 07:58 am, Mark Spieth wrote:
> I have implemented a patch that allows avis to be played and seeked
> correctly. it shows correct length too! I know its a bit of a nasty hack.
> The reasons for doing it this way is to minimise the impact on libavformat
> which Isaac has stressed. Thus avidec.c has 1 new function and is thus easy
> to merge.
> The new function is the same as avi_read_seek except without the url_fseek.
> It is needed to sync the audio and video stream timestamps otherwise they
> diverge uncontrollably. It is only activated if there is an index in the
> avi file.
> The structures in avidec are partially reproduced in avformatdecoder.cpp to
> allow scanning of the index table. This has been annoying me for a while
> now and have finally done something about it. note that I use myth to play
> my avi's instead of mplayer or xine due to timestretch and thus it was
> higher on my priority list. feedback welcome.

Is there any reason why the avformat seeking functions can't be used for cases
where there's no myth seektable?

Isaac
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


jcaputo1 at comcast

May 4, 2005, 1:39 PM

Post #6 of 16 (2058 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

On Wednesday 04 May 2005 13:52, J. Donavan Stanley wrote:
> John Patrick Poet wrote:
>
> > Mark Spieth wrote:
> >
> >> I have implemented a patch that allows avis to be played and seeked
> >> correctly. it shows correct length too!
> >> I know its a bit of a nasty hack.
> >> The reasons for doing it this way is to minimise the impact on
> >> libavformat which Isaac has stressed.
> >> Thus avidec.c has 1 new function and is thus easy to merge.
> >> The new function is the same as avi_read_seek except without the
> >> url_fseek.
> >> It is needed to sync the audio and video stream timestamps
otherwise
> >> they diverge uncontrollably.
> >> It is only activated if there is an index in the avi file.
> >> The structures in avidec are partially reproduced in
> >> avformatdecoder.cpp to allow scanning of the index table.
> >> This has been annoying me for a while now and have finally done
> >> something about it.
> >> note that I use myth to play my avi's instead of mplayer or xine
due
> >> to timestretch and thus it was higher on my priority list.
> >> feedback welcome.
> >> cheers
> >> mark
> >
> >
> >
> > I have several videos I have tried to import into Myth in the past.
> > Doing a "mythcommflag --rebuild" has always been ineffectual.
>
>
> That's because the command is "mythcommflag --video"

True; but as you've indicated in the past, the internal player's avi
handling needs work... or have things changed in the past month or two?

-JAC
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


jdonavan at jdonavan

May 4, 2005, 2:42 PM

Post #7 of 16 (2059 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

Joseph A. Caputo wrote:

>On Wednesday 04 May 2005 13:52, J. Donavan Stanley wrote:
>
>
>>John Patrick Poet wrote:
>>
>>
>>>I have several videos I have tried to import into Myth in the past.
>>>Doing a "mythcommflag --rebuild" has always been ineffectual.
>>>
>>>
>>That's because the command is "mythcommflag --video"
>>
>>
>
>True; but as you've indicated in the past, the internal player's avi
>handling needs work... or have things changed in the past month or two?
>
>
Nope nothing has changed as of yet, it's on my stack but not high enough
for me to spend time on it yet. That being said having a seek table
built for an avi is better than not having one, hence my trying to
clarify things.

_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


jdonavan at jdonavan

May 4, 2005, 2:43 PM

Post #8 of 16 (2052 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

John Patrick Poet wrote:

>On Wed, 4 May 2005, J. Donavan Stanley wrote:
>
>
>
>>That's because the command is "mythcommflag --video"
>>
>>
>
>Aah. Okay, for some reason I though that had to do with mythvideo instead
>of mythtv. I will give that a try.
>
>

I assumed that if you were trying to work with AVIs you weren't trying
to treat them as recordings...
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


john at BlueSkyTours

May 4, 2005, 3:20 PM

Post #9 of 16 (2049 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

On Wed, 4 May 2005, J. Donavan Stanley wrote:

> John Patrick Poet wrote:
>
> >On Wed, 4 May 2005, J. Donavan Stanley wrote:
> >
> >
> >
> >>That's because the command is "mythcommflag --video"
> >>
> >>
> >
> >Aah. Okay, for some reason I though that had to do with mythvideo instead
> >of mythtv. I will give that a try.
> >
> >
>
> I assumed that if you were trying to work with AVIs you weren't trying
> to treat them as recordings...


I record *everything* in HD using my HD-3000 cards. About once every two
months, one of my local stations or another will have a glitch in their HD
transmission. When this happens I grab the corrupt episode using BT (I know
that BT is a four letter word). For convience when managing the episodes it
would be nice to integrate the "BT" episode into the "recordings" section of
Myth.

With Mark's patch this is actually now doable. Without it, saving
positions, etc, did not work with these "BT" episodes -- unless I transcoded
them.

John


mark at dclabs

May 4, 2005, 4:34 PM

Post #10 of 16 (2030 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

> I have several videos I have tried to import into Myth in the past.
> Doing a "mythcommflag --rebuild" has always been ineffectual.
tried this too. didnt work. will try --video to see if that works.

> After a jump to a new location in the file, the video is corrupt for a
> few seconds, but then it clears up and looks fine. Small price to pay
> to actually be able import these files into the main Myth system.

I dont get any corruption so not sure why you get this.

mark
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


mark at dclabs

May 4, 2005, 4:42 PM

Post #11 of 16 (2010 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

> Is there any reason why the avformat seeking functions can't be used for
cases
> where there's no myth seektable?

Im not sure how the whole thing hangs together but the IO routines are
overridden to use ringbuffer functions and seek only works on a byte offset
value.
the avformat functions including seek and read I dont believe are used as
the stream interface is used.
this might confuse the stream reader. so I chose to remain with the existing
interface and just adjust things minimally.
as I said its a big hack and there is probably a better way.
but the url_fseek call in avi_read_seek is the problem I had to get around
for minimum impact on the ringbuffer stream reader (local file mode).
does the avi_read_packet function get called eventually?
as far as I can tell the answer is no. thus no byteiocontext is being used.
I could be wrong (and probably am =).

cheers
mark

_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


mark at dclabs

May 4, 2005, 4:44 PM

Post #12 of 16 (2045 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

> > I have several videos I have tried to import into Myth in the past.
> > Doing a "mythcommflag --rebuild" has always been ineffectual.

note this may not be good enough as the audio part is not resynced,
and the timestamps not adjusted after the seek.
the timestamp relationship between video and audio streams is not very
linear or predictable.
will test

mark

_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


ijr at case

May 4, 2005, 6:04 PM

Post #13 of 16 (2039 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

On Wednesday 04 May 2005 07:42 pm, Mark Spieth wrote:
> Im not sure how the whole thing hangs together but the IO routines are
> overridden to use ringbuffer functions and seek only works on a byte offset
> value.
> the avformat functions including seek and read I dont believe are used as
> the stream interface is used.
> this might confuse the stream reader. so I chose to remain with the
> existing interface and just adjust things minimally.
> as I said its a big hack and there is probably a better way.
> but the url_fseek call in avi_read_seek is the problem I had to get around
> for minimum impact on the ringbuffer stream reader (local file mode).
> does the avi_read_packet function get called eventually?
> as far as I can tell the answer is no. thus no byteiocontext is being used.
> I could be wrong (and probably am =).

I'm _fairly_ sure that av_seek_frame() should do the right thing for an avi,
even with our replaced i/o functions. We just need a frame number, that way,
and it'll use avformat's internal index.

Isaac
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


mark at dclabs

May 4, 2005, 6:39 PM

Post #14 of 16 (2018 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

> I'm _fairly_ sure that av_seek_frame() should do the right thing for an
avi,
> even with our replaced i/o functions. We just need a frame number, that
way,
> and it'll use avformat's internal index.

I have no doubt that that would work.
however, the file io is not being performed by the same engine, and the file
handle(s) are not consistent (I think).
seeking with one handle and reading in the other is not a good thing.
this is what complicates things.
mark

_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


ijr at case

May 4, 2005, 7:07 PM

Post #15 of 16 (2046 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

On Wednesday 04 May 2005 09:39 pm, Mark Spieth wrote:
> > I'm _fairly_ sure that av_seek_frame() should do the right thing for an
>
> avi,
>
> > even with our replaced i/o functions. We just need a frame number, that
>
> way,
>
> > and it'll use avformat's internal index.
>
> I have no doubt that that would work.
> however, the file io is not being performed by the same engine, and the
> file handle(s) are not consistent (I think).
> seeking with one handle and reading in the other is not a good thing.
> this is what complicates things.

I have no idea what you're talking about. The seek would go through the
ringbuffer just like all other i/o in libavformat would.

Isaac
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


mark at dclabs

May 4, 2005, 8:25 PM

Post #16 of 16 (2039 views)
Permalink
Re: [PATCH] better avi seek support [In reply to]

> I have no idea what you're talking about. The seek would go through the
> ringbuffer just like all other i/o in libavformat would.
>
I have delved a bit more deeply and I see a better more generic way.
my lack of understanding of the hooks.
should be another patch this weekend if I dont get time earlier.
mark
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

MythTV dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.