[FFmpeg-devel] Fixing av_seek

Don Moir donmoir at comcast.net
Tue Jan 31 03:05:22 CET 2012


>> o - No frames are marked as keyframes. avformat_seek_file returns -1. I
>> think I only have one file like this so we could say this is a rare case. 
>> I
>> just make sure I at least seek to the first frame. In order to keep
>> avformat_seek_file from failing, you have to mark the first frame as a 
>> key
>> frame and I do this. The one file I have like this is filecopy.avi and it
>> can be found here: https://ffmpeg.org/trac/ffmpeg/ticket/504

> patch to fix this one posted to teh ML

Thank You.

>> o - The ogg decoder read_seek function is weak. It does not make an 
>> attempt
>> to create it's index_entries and without these seeking is going to be 
>> bad.
>> This is outlined here: https://ffmpeg.org/trac/ffmpeg/ticket/941
>>
>> o - The matroska decoder read_seek function has a couple bugs that 
>> effects
>> at least one file I have and that is outlined here:
>> https://ffmpeg.org/trac/ffmpeg/ticket/958
>>
>> With the above changes, things work very well but there are a few odd 
>> cases
>> still. These cases don't effect things too much. Mostly just a lag after
>> seeking is done and before the next frame can be displayed. This happens
>> only on a few ogg files and matroska files that I know of. It could be
>> because of improper timestamps, improper index_entries, or even just a 
>> bad
>> file. Not sure.

> I would be quite interrested to see patches for the changes you did.

Me too :)

It's good to see that some you of work very hard on ffmpeg. I basically work 
24/7, but mostly I cannot focus on ffmpeg alone. The work I get paid to do 
has already fallin behind and I have people complaining about that. 
(contract work).

I had to get ffmpeg working to a point where seeking worked so hopefully 
there can be some kind of payoff for it. Initially I got ffmpeg to compile 
using MinGW and thats fine. I never have gotten to the point of compiling in 
all the necessary libraries etc. Never have taken the time to deal with fate 
and whatever else I have to do to provide a proper patch. There is only so 
much time I can spend on it.

I have not changed any of the code in ffmpeg. I deal with the issues at a 
higher level but I don't want to.  I have taken the time to pin point issues 
for you when I can but I do not necessarily have the best insight on how to 
fix some of them.

For example:

o - with the ogg problem, there is mostly like a better / faster way then to 
read packets and dump them just to create the index_entries it needs. To do 
this correctly means getting deeper into that code.

o - for the matroska problem, I am not sure why 0 is being used as an EOF 
indicator ebml_parse so that probably takes some additional knowledge to 
make sure that does the right thing. I also check this condtion at a higher 
level and in the worst case of that one file indicated in ticket #958 I have 
to seek twice. If it succeeds correcly on the first seek I am done If not I 
have call the slower create_index_entries functions (attached) and seek 
again. That one file is the only file out of about 200 that this problem is 
detected so not too bad.

I will be more than happy to post any code and will post the end result of 
my seek functions. Some of it is probably best done at an application level 
and some of it may be able to be worked into ffmpeg. The real thing is to 
keep avformat_seek file from failing or doing the wrong thing and the 2 
tickets above are the worse cases I have run into and they detail the 
problems. My work around for the ogg decoder is just a read / free packet 
until I reach the timestamp of interest for a stream, but this is not 
optimal. The attached file shows what I currently do but this should be 
optimized for the ogg decoder similiar to what the matroska decoder does in 
it's read_seek function.

My apps are done in MS dev studio. It's a pain to debug ffmpeg from there 
since the MinGW debug symbols are not compatible with it. I can deal with 
this though. It would be nice if ffmpeg could be made compatible with the 
Intel compiler at least. ffmpeg almost compiles with the Intel compiler. 
Nothing that a few hundred minor patches and a few days worth of work 
wouldn't take care of :) Most of your end user type of apps are done for 
windows and mac and you might get better feedback and bug fixes if it could 
compile with dev studio and at least the Intel compiler.I will check if 
there is a compiler for dev-studio that might work better, but as far as I 
know it's either MS or Intel.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: check_index_entries.txt
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120130/235f0b31/attachment.txt>


More information about the ffmpeg-devel mailing list