formats¶
This module provides the transport layer interface: encoded packets, Muxer, Demuxers and their support code.
- class pyrana.formats.AVFmtFlags¶
wrapper for the (wannabe)enum in libavformat/avformat.h
- class pyrana.formats.Demuxer(src, name=None, delay_open=False, streaming=False)¶
Demuxer object. Use a file-like for real I/O. The file-like must be already open, and must support read() returning bytes (not strings). If the file format is_seekable but the file-like doesn’t support seek, expect weird things.
- close()¶
close the underlying demuxer.
- next()¶
python 2.x iterator hook.
- open(name=None)¶
open the underlying demuxer.
- open_decoder(stream_id)¶
create and returns a full-blown decoder Instance capable to decode the selected stream. Like doing things manually, just easily.
- read_frame(stream_id=-1)¶
reads and returns a new complete encoded frame (enclosed in a Packet) from the demuxer. if the optional `stream_id’ argument is !ANY, returns a frame belonging to the specified streams.
raises EndOfStreamError if - a stream id is specified, and such streams doesn’t exists. - the streams ends.
- seek_frame(frameno, stream_id=-1)¶
seek to the given frame number in the stream.
- seek_ts(tstamp, stream_id=-1)¶
seek to the given timestamp (msecs) in the stream.
- stream(sid=-1)¶
generator that returns all packets that belong to a specified stream id.
- streams¶
streams: read-only attribute list of StreamInfo objects describing the streams found by the demuxer (as in old pyrana, no changes)
- class pyrana.formats.FormatFlags¶
wrapper for the (wannabe)enum of AVFormatFlags in libavformat/avformat.h
- class pyrana.formats.Muxer(sink, name=None, streaming=True)¶
Muxer object. Use a file-like for real I/O. The file-like must be already open, and must support write() returning bytes (not strings). If the file format is_seekable but the file-like doesn’t support seek, expect weird things.
- add_stream(encoder)¶
register a new stream into the Muxer for the given Encoder. XXX add more docs
- open_encoder(output_codec, params)¶
create and returns a full-blown enccoder Instance capable, given the encoder parameters, already bound and registered as stream in the Muxer.
- write_frame(packet)¶
writes a data frame, enclosed into an encoded Packet, in the stream.
- write_header()¶
Writes the header into the output stream.
- write_trailer()¶
Writes the trailer (if any) into the output stream. Requires the header to be written (and, likely, some data) Must be the last operation before to release the Muxer.
- class pyrana.formats.SeekFlags¶
wrapper for the (wannabe)enum of AVSeekFlags in libavformat/avformat.h
- pyrana.formats.find_stream(streams, nth, media)¶
find the nth stream of the specified media a streams info (as in Demuxer().streams). Return the corresponding stream_id. Raise NotFoundError otherwise.