|Reported by:||DonMoir||Owned by:|
|Blocking:||Reproduced by developer:||no|
|Analyzed by developer:||no|
libavutil 51. 16. 1 / 51. 16. 1
libavcodec 53. 16. 0 / 53. 16. 0
libavformat 53. 12. 0 / 53. 12. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 43. 2 / 2. 43. 2
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
av_seek_frame fails in several cases. This is an attempt to write a seek function that works as expected. It may be that avformat_seek_file will be an attempt to fix all this, but currently it just calls av_seek_frame since read_seek2 does not exist. So mostly this needs to be a rewrite of libavformat\utils.c.
I see that alot of the failures occur because the AVStream index_entries is NULL or none of the entries are flaged with AVINDEX_KEYFRAME, but there are other reasons for failure and thats going to require more digging.
This discussion is probably going to end up being lengthy. I have several files that fail but they fail for various reasons. If you want I will just put it all on this ticket, or open a new ticket for each case, or we can just communicate by email. Let me know.
This first case is the simplest I have. It has index_entries but none of them are flagged with AVINDEX_KEYFRAME. It has read_seek but that returns -1. It ends up calling seek_frame_generic which calls av_index_search_timestamp and that fails since none of the entries are marked with AVINDEX_KEYFRAME. So the end result of av_seek_frame is -1. You cannot just call av_seek_frame with AVSEEK_FLAG_ANY because that will just put you in the middle somewhere and that will produce incorrect results when you decode it. For looping back to the beginning, using AVSEEK_FLAG_ANY will work since the reality here is the first frame is the key frame. In order to correcly seek into this file at an arbitrary position, I suppose you would need to decode the first frame and then proceed to the timestamp of interest. The attached file, filecopy.avi, can be tested with ffplay by using the left arrow key and you will see it says 'error while seeking'.
This is just the first case. I have several others but maybe by fixing a few these it will cover most cases.
Another note for now is when av_seek_frame_binary is called, there are 2 variables called pos_min and pos_max. I have files where av_seek_frame_binary is called and either 1 or 2 of the variables are never initialized. Then av_gen_search is called with the unintialized variables. I will get back to this later with file examples.