Skip to content

Conversation

tikuma-lsuhsc
Copy link
Contributor

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:

self.flush_buffers()

It fails the test_decode_half and test_stream_seek because seeking after reaching the EOF does not reinstate the codecs. To get the codecs output of the EOF, we must call flush_buffers().

To satisfy these conditions, this PR adds an eof flag to InputContainer and adopted the EOF checking mechanism from ffplay: https://github.com/FFmpeg/FFmpeg/blob/673f28b6cb6e20f5a695a90d144a6158bdf987fe/fftools/ffplay.c#L3098

P.S., I've also added InputContainer.seek2() method which wraps avformat_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.

@WyattBlue WyattBlue added the needs tests This PR needs a test label Aug 24, 2025
@tikuma-lsuhsc
Copy link
Contributor Author

Sorry, I pulled the gun a little too early. This still doesn't fix the problem. I'll investigate further.

@tikuma-lsuhsc tikuma-lsuhsc deleted the fix-seek-buffer-flush branch September 1, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs tests This PR needs a test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants