Streams¶
Stream collections¶
-
class
av.container.streams.StreamContainer¶ Bases:
objectA tuple-like container of
Stream.# There are a few ways to pulling out streams. first = container.streams[0] video = container.streams.video[0] audio = container.streams.get(audio=(0, 1))
Dynamic Slicing¶
-
StreamContainer.get(streams=None, video=None, audio=None, subtitles=None, data=None)¶ Get a selection of
Streamas alist.Positional arguments may be
int(which is an index into the streams), orlistortupleof those:# Get the first channel. streams.get(0) # Get the first two audio channels. streams.get(audio=(0, 1))
Keyword arguments (or dicts as positional arguments) as interpreted as
(stream_type, index_value_or_set)pairs:# Get the first video channel. streams.get(video=0) # or streams.get({'video': 0})
Streamobjects are passed through untouched.If nothing is selected, then all streams are returned.
Typed Collections¶
These attributes are preferred for readability if you don’t need the
dynamic capabilities of get():
-
StreamContainer.video¶ A tuple of
VideoStream.
-
StreamContainer.audio¶ A tuple of
AudioStream.
-
StreamContainer.subtitles¶ A tuple of
SubtitleStream.
-
StreamContainer.data¶ A tuple of
DataStream.
-
StreamContainer.other¶ A tuple of
Stream
Streams¶
-
class
av.stream.Stream¶ Bases:
objectA single stream of audio, video or subtitles within a
Container.-
average_rate¶ The average frame rate of this stream.
Type: fractions.Fraction
-
codec_context¶
-
decode(packet=None)¶ Decode a
Packetand return a list ofAudioFrameorVideoFrame.
-
encode(frame=None)¶ Encode an
AudioFrameorVideoFrameand return a list ofPacket.
-
metadata¶
-
seek(offset, whence='time', backward=True, any_frame=False)¶ See also
InputContainer.seek()for documentation on parameters. The only difference is thatoffsetwill be interpreted inStream.time_basewhenwhence == 'time'.Deprecated since version 6.1.0: Use
InputContainer.seek()withstreamargument instead.
-
start_time¶ The presentation timestamp in
time_baseunits of the first frame in this stream.Returns None if it is not known.
Type: int
-
time_base¶ The unit of time (in fractional seconds) in which timestamps are expressed.
Type: fractions.Fraction
-