diff --git a/av/format.pyx b/av/format.pyx index 26d501440a8db3cce037ef9c69fcec5bb4188a85..2df4d8449ec26bae7c89476550bdcb1c34af7833 100644 --- a/av/format.pyx +++ b/av/format.pyx @@ -79,8 +79,13 @@ cdef class Context(object): break if include_stream[packet.struct.stream_index]: - packet.stream = self.streams[packet.struct.stream_index] - yield packet + # If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams + # may also appear in av_read_frame(). + # http://ffmpeg.org/doxygen/trunk/structAVFormatContext.html + # TODO: find better way to handle this + if packet.struct.stream_index < len(self.streams): + packet.stream = self.streams[packet.struct.stream_index] + yield packet # Some codecs will cause frames to be buffered up in the decoding process. # These codecs should have a CODEC CAP_DELAY capability set.