Containers¶
-
class
av.container.
Container
¶ Bases:
object
-
container_options
¶
-
dumps_format
()¶
-
file
¶
-
format
¶
-
metadata
¶
-
metadata_encoding
¶
-
metadata_errors
¶
-
name
¶
-
options
¶
-
stream_options
¶
-
streams
¶
-
writeable
¶
-
Input Containers¶
-
class
av.container.
InputContainer
¶ Bases:
av.container.core.Container
-
bit_rate
¶
-
decode
(streams=None, video=None, audio=None, subtitles=None, data=None)¶ Yields a series of
Frame
from the given set of streams:for frame in container.decode(): # Do something with `frame`.
See also
StreamContainer.get()
for the interpretation of the arguments.
-
demux
(streams=None, video=None, audio=None, subtitles=None, data=None)¶ Yields a series of
Packet
from the given set ofStream
:for packet in container.demux(): # Do something with `packet`, often: for frame in packet.decode(): # Do something with `frame`.
See also
StreamContainer.get()
for the interpretation of the arguments.Note
The last packets are dummy packets that when decoded will flush the buffers.
-
duration
¶
-
seek
(offset, whence='time', backward=True, any_frame=False, stream=None)¶ Seek to a (key)frame nearsest to the given timestamp.
Parameters: - offset (int) – Location to seek to. Interpretation depends on
whence
. - whence (str) – One of
'time'
,'frame'
, or'byte'
- backward (bool) – If there is not a (key)frame at the given offset, look backwards for it.
- any_frame (bool) – Seek to any frame, not just a keyframe.
- stream (Stream) – The stream who’s
time_base
theoffset
is in.
whence
has the following meanings:'time'
:offset
is instream.time_base
ifstream
elseav.time_base
.'frame'
:offset
is a frame index'byte'
:offset
is the byte location in the file to seek to.
Warning
Not all formats support all options, and may fail silently.
- offset (int) – Location to seek to. Interpretation depends on
-
size
¶
-
start_time
¶
-
Output Containers¶
-
class
av.container.
OutputContainer
¶ Bases:
av.container.core.Container
-
add_stream
(codec_name, rate=None)¶ Create a new stream, and return it.
Parameters: - codec_name (str) – The name of a codec.
- rate – The frame rate for video, and sample rate for audio.
Examples for video include
24
,23.976
, andFraction(30000,1001)
. Examples for audio include48000
and44100
.
Returns: The new
Stream
.
-
close
(strict=False)¶
-
mux
(packets)¶
-
mux_one
(Packet packet)¶
-
start_encoding
()¶ Write the file header! Called automatically.
-