fixed seek operation when not at eof #1989
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a PR to resolve Issue #1987 ("Seek succeeds but any frame read is all zeros [revisited]") that I posted earlier.
The problem was that the said AVI format and configuration cannot have the codec buffer flushed if not at the end of the file. I studied FFmpeg's
ffplay.c
for their handling of during-playback seeks, and the only difference is that they do not flush the codec buffers.If we simply remove:
PyAV/av/container/input.pyx
Line 279 in 0b85c60
It fails the
test_decode_half
andtest_stream_seek
because seeking after reaching the EOF does not reinstate the codecs. To get the codecs output of the EOF, we must callflush_buffers()
.To satisfy these conditions, this PR adds an
eof
flag toInputContainer
and adopted the EOF checking mechanism from ffplay: https://github.com/FFmpeg/FFmpeg/blob/673f28b6cb6e20f5a695a90d144a6158bdf987fe/fftools/ffplay.c#L3098P.S., I've also added
InputContainer.seek2()
method which wrapsavformat_seek_file()
to my fork while I was investigating this issue. I'd be happy to add it to this PR (or as another PR) if you find it a reasonable addition to the class.