Common code shared by audio and video codecs. This module is not part of the pyrana public API.
Decoder base class. Common both to audio and video decoders.
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.
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 Decoder from (around) a (cffi-wrapped) libav* decoder object. The libav object must be already initialized and ready to go. WARNING: raw access. Use with care.
opens the codec into the codec context.
Encoder base class. Common both to audio and video encoders.
Encode a logical frame in one or possibly more)packets, and return an iterable which will yield all the packets produced.
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 Encoder from (around) a (cffi-wrapped) libav* decoder object. The libav object must be already initialized and ready to go. WARNING: raw access. Use with care.
Abstract Frame class. Provides bookkeeping and access to attributes common to frames of all media types. Do not use directly.
Direct access to the internal C AVFrame object.
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.
Is this a key frame?
The Presentation TimeStamp of this Frame.
wrapper for the (wannabe) enum in avcodec.h CODEC_FLAG_*
wrapper for the (wannabe) enum in avcodec.h CODEC_FLAG2_*
Mixin. Abstracts the common codec attributes: parameters reference, read-only access, extradata management.
bytearray-like, read-write
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.
Generic media-agnostic frame payload.
returns the bytes() dump of the object.
allocates an AVFrame and cleans it up on exception.
Finds a suitable encoder for the given output codec. Raises SetupError if the codec isn’t supported.
builds the right decoder for a given stream of an AVCodecContext.
Builds a callable which extracts, deletes from the originating sequence-like (either materialized or generating) and returns an item.
Setups the common fields of every multimedia payload object.
Injects the specific decoding hooks in a generic decoder.
Injects the specific encoding hooks in a generic encoder.