Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions av/container/input.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ from av.stream cimport Stream

cdef class InputContainer(Container):

cdef bint eof

cdef flush_buffers(self)
5 changes: 4 additions & 1 deletion av/container/input.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ cdef class InputContainer(Container):
ret = lib.av_read_frame(self.ptr, packet.ptr)
self.err_check(ret)
except EOFError:
self.eof = True
break

if include_stream[packet.ptr.stream_index]:
Expand Down Expand Up @@ -276,7 +277,9 @@ cdef class InputContainer(Container):
ret = lib.av_seek_frame(self.ptr, stream_index, c_offset, flags)
err_check(ret)

self.flush_buffers()
# codec buffers must be cleared if file is at eof,
if self.eof or lib.avio_feof(self.ptr.pb):
self.flush_buffers()

cdef flush_buffers(self):
self._assert_open()
Expand Down
2 changes: 2 additions & 0 deletions include/libavformat/avformat.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ cdef extern from "libavformat/avformat.h" nogil:

cdef int avio_closep(AVIOContext **s)

cdef int avio_feof(AVIOContext *s)

cdef int avformat_find_stream_info(
AVFormatContext *ctx,
AVDictionary **options, # Can be NULL.
Expand Down
Loading