Containers¶
Generic¶
- class av.container.Container¶
Bases:
object
- options¶
- container_options¶
- stream_options¶
- metadata_encoding¶
- metadata_errors¶
- open_timeout¶
- read_timeout¶
Flags¶
- av.container.Container.flags¶
- class av.container.Flags¶
Wraps AVFormatContext.flags.
Container Attribute
Flags Name
Flag Value
Meaning in FFmpeg
Input Containers¶
- class av.container.InputContainer¶
Bases:
Container
- bit_rate¶
- close()¶
- 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, *, backward=True, any_frame=False, stream=None)¶
Seek to a (key)frame nearsest to the given timestamp.
- Parameters:
offset (int) – Time to seek to, expressed in``stream.time_base`` if
stream
is given, otherwise inav.time_base
.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.unsupported_frame_offset (bool) –
offset
is a frame index instead of a time; not supported by any known format.unsupported_byte_offset (bool) –
offset
is a byte location in the file; not supported by any known format.
After seeking, packets that you demux should correspond (roughly) to the position you requested.
In most cases, the defaults of
backwards = True
andany_frame = False
are the best course of action, followed by you demuxing/decoding to the position that you want. This is becase to properly decode video frames you need to start from the previous keyframe.See also
avformat_seek_file for discussion of the flags.
- size¶
- start_time¶
Output Containers¶
- class av.container.OutputContainer¶
Bases:
Container
- add_data_stream(codec_name=None)¶
Creates a new data stream and returns it.
- add_stream(codec_name, rate=None)¶
Creates a new stream from a codec name and returns it. Supports video, audio, and subtitle streams.
- add_stream_from_template(Stream template, **kwargs)¶
Creates a new stream from a template. Supports video, audio, and subtitle streams.
- close()¶
- default_audio_codec¶
Returns the default audio codec this container recommends.
- default_subtitle_codec¶
Returns the default subtitle codec this container recommends.
- default_video_codec¶
Returns the default video codec this container recommends.
- mux(packets)¶
- mux_one(Packet packet)¶
- start_encoding()¶
Write the file header! Called automatically.
- supported_codecs¶
Returns a set of all codecs this format supports.
Formats¶
- ContainerFormat.name¶
- ContainerFormat.long_name¶
- ContainerFormat.options¶
- ContainerFormat.input¶
An input-only view of this format.
- ContainerFormat.output¶
An output-only view of this format.
- ContainerFormat.is_input¶
- ContainerFormat.is_output¶
- ContainerFormat.extensions¶