Video¶
Video Streams¶
-
class
av.video.stream.
VideoStream
¶ Bases:
av.stream.Stream
-
average_rate
¶ The average frame rate of this stream.
Type: fractions.Fraction
-
Video Codecs¶
-
class
av.video.codeccontext.
VideoCodecContext
¶ Bases:
av.codec.context.CodecContext
-
coded_height
¶
-
coded_width
¶
-
display_aspect_ratio
¶
-
encoded_frame_count
¶
-
format
¶
-
framerate
¶ The frame rate, in frames per second.
Type: fractions.Fraction
-
gop_size
¶
-
has_b_frames
¶
-
height
¶
-
pix_fmt
¶
-
reformatter
¶
-
sample_aspect_ratio
¶
-
width
¶
-
Video Formats¶
-
class
av.video.format.
VideoFormat
¶ Bases:
object
>>> format = VideoFormat('rgb24') >>> format.name 'rgb24'
-
chroma_height
(luma_height=0)¶ Height of a chroma plane relative to a luma plane.
Parameters: luma_height (int) – Height of the luma plane; defaults to self.height
.
-
chroma_width
(luma_width=0)¶ Width of a chroma plane relative to a luma plane.
Parameters: luma_width (int) – Width of the luma plane; defaults to self.width
.
-
components
¶
-
has_palette
¶ Pixel format has a palette in data[1], values are indexes in this palette.
-
height
¶
-
is_big_endian
¶ Pixel format is big-endian.
-
is_bit_stream
¶ All values of a component are bit-wise packed end to end.
-
is_planar
¶ At least one pixel component is not in the first data plane.
-
is_rgb
¶ The pixel format contains RGB-like data (as opposed to YUV/grayscale).
-
name
¶ Canonical name of the pixel format.
-
width
¶
-
-
class
av.video.format.
VideoFormatComponent
¶ Bases:
object
-
bits
¶ Number of bits in the component.
-
height
¶ The height of this component’s plane.
Requires the parent
VideoFormat
to have a height.
-
index
¶
-
is_alpha
¶ Is this component an alpha channel?
-
is_chroma
¶ Is this component a chroma channel?
-
is_luma
¶ Is this compoment a luma channel?
-
plane
¶ The index of the plane which contains this component.
-
width
¶ The width of this component’s plane.
Requires the parent
VideoFormat
to have a width.
-
Video Frames¶
-
class
av.video.frame.
VideoFrame
¶ Bases:
av.frame.Frame
A frame of video.
>>> frame = VideoFrame(1920, 1080, 'rgb24')
-
width
¶ Width of the image, in pixels.
-
height
¶ Height of the image, in pixels.
-
format
¶
-
static
from_image
(img)¶ Construct a frame from a PIL.Image.
-
static
from_ndarray
(array, format='rgb24')¶ Construct a frame from a numpy array.
-
interlaced_frame
¶ Is this frame an interlaced or progressive?
-
key_frame
¶ Is this frame a key frame?
-
pict_type
¶
-
reformat
(width=None, height=None, format=None, src_colorspace=None, dst_colorspace=None)¶ Create a new
VideoFrame
with the given width/height/format/colorspace.Parameters: - Supported colorspaces are currently:
'itu709'
'fcc'
'itu601'
'itu624'
'smpte240'
'default'
orNone
-
to_image
(**kwargs)¶ Get an RGB
PIL.Image
of this frame.Any
**kwargs
are passed toVideoFrame.reformat()
.Note
PIL or Pillow must be installed.
-
to_ndarray
(**kwargs)¶ Get a numpy array of this frame.
Any
**kwargs
are passed toVideoFrame.reformat()
.Note
Numpy must be installed.
-
to_rgb
(**kwargs)¶ Get an RGB version of this frame.
Any
**kwargs
are passed toVideoFrame.reformat()
.>>> frame = VideoFrame(1920, 1080) >>> frame.format.name 'yuv420p' >>> frame.to_rgb().format.name 'rgb24'
-