this module provides the video codec interface. Encoders, Decoders and their support code.
Decodes video Packets into video Frames.
Decode data from a logical stream of packets, and returns when the first next frame is available. The input stream can be - a materialized sequence of packets (list, tuple...) - a generator (e.g. Demuxer.stream()).
Generator method. Decode a single packet (as in returned by a Demuxer) and extracts all the frames encoded into it. An encoded packet can legally contain more than one frame, altough this is not so common. This method deals with the [one packet -> many frames] scenario. The internal underlying decoder does its own buffer, so you can freely dispose the packet(s) fed into this method after it exited. raises ProcessingError if decoding fails; raises NeedFeedError if decoding partially succeeds, but more data is needed to reconstruct a full frame.
bytearray-like, read-write
emits all frames that can be recostructed by the data buffered into the Decoder, and empties such buffers. Call it last, do not intermix with decode*() calls. caution: more than one frame can be buffered. Raises NeedFeedError if all the internal buffers are empty.
builds a pyrana Video Decoder from (around) a (cffi-wrapped) libav* (video)decoder object. The libav object must be already initialized and ready to go. WARNING: raw access. Use with care.
the codec media type.
opens the codec into the codec context.
the codec parameters.
is the codec readu to go?
Dispach the given parameters to the internal (FFmpeg) data structures.
wire up the Decoder. See codec.wire_decoder
Encode video Frames into Packets.
Encode a logical frame in one or possibly more)packets, and return an iterable which will yield all the packets produced.
bytearray-like, read-write
emits all packets which may have been buffered by the Encoder and empties such buffers. Call it last, do not intermix with encode*() calls. caution: more than one encoded frame (thus many packets) can be buffered. Raises NeedFeedError if all the internal buffers are empty.
builds a pyrana video Encoder from (around) a (cffi-wrapped) liabv* (audio) context. WARNING: raw access. Use with care.
the codec media type.
opens the codec into the codec context.
the codec parameters.
is the codec readu to go?
Dispach the given parameters to the internal (FFmpeg) data structures.
wire up the Encoder. See codec.wire_encoder
A Video frame.
The sample aspect ratio of the frame.
Direct access to the internal C AVFrame object.
Picture number in bitstream order.
Picture number in display order.
builds a pyrana generic Base Frame from (around) a (cffi-wrapped) libav* AVFrame object. The libav object must be already initialized and ready to go. WARNING: raw access. Use with care.
Returns a new Image object which provides access to the Picture (thus the pixel as bytes()) data.
Is the content of the picture interlaced?
Is this a key frame?
Picture type of the frame, see AVPictureType.
The Presentation TimeStamp of this Frame.
If is_interlaced(), is top field displayed first?
Represents the Picture data inside a Frame.
returns the bytes() dump of the object.
convert the Image data in a new PixelFormat. returns a brand new, independent Image.
builds a pyrana Image from a (cffi-wrapped) libav* Frame object. The Picture data itself will still be hold in the Frame object. The libav object must be already initialized and ready to go. WARNING: raw access. Use with care.
Frame height. Expected to be always equal to the stream height.
Is the underlying C-Frame shared with the parent py-Frame?
Frame pixel format. Expected to be always equal to the stream pixel format.
Read-only byte access to a single plane of the Image.
Return the number of planes in the Picture data. e.g. RGB: 1; YUV420: 3
Frame width. Expected to be always equal to the stream width.
SWS operational flags. This wasn’t a proper enum, rather a collection of #defines, and that’s the reason why it is defined here.
fill a video frame with a test pattern.