Avpy Documentation. Release sydh

Similar documents
BanzaiDB Documentation

WordEmbeddingLoader Documentation

pysharedutils Documentation

obfuscator Documentation

python-quirc Documentation

goose3 Documentation Release maintainers

python-twitch-stream Documentation

Pulp Python Support Documentation

FFmpeg The Media Swiss Army Knife. Jess Portnoy Kaltura, Inc

streamio Documentation

Qualcomm High Efficiency Video Coding (HEVC) Video Encoder

gpib-ctypes Documentation

petfinder-api Documentation

python-anyvcs Documentation

Module 10 MULTIMEDIA SYNCHRONIZATION

ffmpy Documentation Andriy Yurchuk

Python Overpass API Documentation

Gecata by Movavi 5. Recording desktop. Recording with webcam Capture videos of the games you play. Record video of your full desktop.

Archan. Release 2.0.1

User manual. (Onvif Rtsp Server) Happytimesoft Technology Co.,LTD

ffmpy3 Documentation Release Eric Ahn

ZeroVM Package Manager Documentation

PROBLEMS AND POSSIBLE INPROVEMENTS...

python-ipfix Documentation

django-embed-video Documentation

MyAnimeList Scraper. Release 0.3.0

Flash Video MX COM Edition

mpl Release latest May 17, 2017

File test version. DPP Compliance Programme AMWA / UK DPP -- AS-11 UK DPP HD Shim v1.1 File Conformance Test Suite

Scientific Working Group on Digital Evidence

Python Finite State Machine. Release 0.1.5

PySoundFile Documentation Release 0.6.0

Online Help Browser Requirements Safari *Please note: Episode 7 does not support OS X or previous versions of Mac OS X.

Django-CSP Documentation

e24paymentpipe Documentation

django-auditlog Documentation

Revision 4.1.x /2.x.x [ ] Creating Media for Modulo Player & Kinetic

python-lz4 Documentation

Video Quality Monitoring

python-unrar Documentation

websnort Documentation

NVJPEG. DA _v0.2.0 October nvjpeg Libary Guide

Redis Timeseries Documentation

msgpack Documentation

Request for Comments: 4425 Category: Standards Track February 2006

WHITE PAPER. Director Prof. Dr.-Ing. Albert Heuberger Am Wolfsmantel Erlangen

Export Audio Mixdown

Durga Documentation. Release dev2. transcode

bottle-rest Release 0.5.0

HyDe Documentation. Release 0.4.1a. Paul Blischak and Laura Kubatko

g-pypi Documentation Release 0.3 Domen Kožar

pyvcd Documentation Release Peter Grayson and Steven Sprouse

Release Notes. This is BATON Standard version 7.2 for installation on Windows 64-bit platform.

dicompyler-core Documentation

pymonetdb Documentation

tinycss Documentation

Can Lightworks support JVC Everio file format? Posted by davidomatic - 17 Apr :51

python-samplerate Documentation

Opus Generated by Doxygen Thu May :22:05

pytest-benchmark Release 2.5.0

Unable to import a video file into Lightworks Posted by Slashbuddy24-03 Mar :50

OTX to MISP. Release 1.4.2

Seshat Documentation. Release Joshua P Ashby

Application Programming Interface (API) for RK Hardware Codec. Application Programming Interface (API) for RK Hardware Codec

Community detection for NetworkX Documentation

Face Recognition Documentation

chatterbot-weather Documentation

GStreamer Status Report: The Road Ahead. GStreamer Conference August 2012 San Diego. Tim-Philipp Müller

Local Music Bot Documentation

spnav Documentation Release 0.9 Stanley Seibert

prompt Documentation Release Stefan Fischer

Gearthonic Documentation

tolerance Documentation

python-json-patch Documentation

nidm Documentation Release 1.0 NIDASH Working Group

Die Brummbeere Documentation

sainsmart Documentation

2.1 Transcoding audio files

MULTIMEDIA AND CODING

Python Utils Documentation

Online Help Browser Requirements Safari *Please note: Episode 7 does not support OS X or previous versions of Mac OS X.

============================================================================

Release Manu Phatak

Simple Plugin API. Wim Taymans Principal Software Engineer October 10, Pinos Wim Taymans

IP Utility. User s Manual For Version

WinCE6.0 MFC SMDKV210. Revision 1.90 October Samsung Electronics Co., Ltd. All rights reserved.

edeposit.amqp.antivirus Release 1.0.1

GMusicProcurator Documentation

geoip2 Documentation Release Gregory Oschwald

NiFpga Example Documentation

redis-lua Documentation

Microlab Instruments Documentation

subliminal Documentation

Saperion Version 7.5 Service Pack 6 Bug Fixes

ACTi IP Utility User s Manual For Version

gst-launch-0 - Linux Command

UHD Player Manual. Version Based on Firmware Version: 1.2.x AV Stumpfl GmbH Austria

MP2TSME v8.0 Release Notes

xtensor-io Sep 20, 2018

Solid State Graphics (SSG) SDK Setup and Raw Video Player Guide

Transcription:

Avpy Documentation Release 0.1.3 sydh May 01, 2016

Contents 1 Overview 1 2 Getting Help 3 3 Issues 5 4 Changes 7 5 Contributions 9 6 Indices and tables 11 6.1 Examples................................................. 11 6.2 Frequently Asked Questions....................................... 12 6.3 avpy................................................... 13 6.4 Changelog................................................ 19 Python Module Index 21 i

ii

CHAPTER 1 Overview Avpy is a ctypes (python) binding for libav and ffmpeg. Examples Code examples. Frequently Asked Questions Some questions that come up often. avpy The complete API documentation, organized by classes and functions. 1

2 Chapter 1. Overview

CHAPTER 2 Getting Help If you re having trouble or have questions, you can write me an email (sydhds at gmail dot com) or create an issue in the bug tracker (see Issues) and mark it as an ehancement or a proposal. 3

4 Chapter 2. Getting Help

CHAPTER 3 Issues All issues should reported at the Avpy bug tracker. 5

6 Chapter 3. Issues

CHAPTER 4 Changes See the Changelog for a full list of changes. 7

8 Chapter 4. Changes

CHAPTER 5 Contributions Fork the git repo and submit a pull request. 9

10 Chapter 5. Contributions

CHAPTER 6 Indices and tables genindex modindex search 6.1 Examples The examples in this section are intended to give in depth overviews of how to accomplish specific tasks in Python. Unless otherwise noted, all examples assume that the Avpy module can be imported. See also: see examples folder in avpy repository 6.1.1 First Steps This example covers your first steps with Avpy. Importing Let s start with printing some media information: from avpy import Media # print media info (streams, codecs...) m = Media('test.avi') print m.info() Going further Try the next example in Examples Explore the API documentation Media 11

6.2 Frequently Asked Questions Contents Frequently Asked Questions Libav and FFmpeg version support? Does Avpy support Python 3? Is the high level API stable? Does Avpy only provide a high level API? 6.2.1 Libav and FFmpeg version support? Libav 0.8, 9, 10 and 11 (all patch version supported) FFmpeg 1.2 (all patch version supported) Note that support for FFmpeg 2.2, 2.4 and 2.5 will be added later. 6.2.2 Does Avpy support Python 3? Yes for Python 3.2+ (pypy is supported as well). Please report if something is broken for Python3. 6.2.3 Is the high level API stable? Short answer: Almost but not yet. Long answer: As the api provides support for decoding and encoding, it should remain almost stable. Some additional code will be provided to abstract as much as possible any ctypes code and to support new features (filtering, audio resampling, seeking...). 6.2.4 Does Avpy only provide a high level API? Short answer: A low level API is available but its usage is not recommended. Long answer: A low level API is available as ctypes functions that directly map the underlying C functions. Note that this API varies from library (ffmpeg or libav) and from version (libav0.8 and libav 9). So while the high level API take cares of theses differences, the low API does not. Available functions are declared in avpy/version/av{version}.py. Please report if some functions are missing. 12 Chapter 6. Indices and tables

6.3 avpy 6.3.1 avpy package Submodules avpy.av module avpy.avmedia module class avpy.avmedia.media(medianame, mode= r, quiet=true) Bases: object init (medianame, mode= r, quiet=true) Initialize a media object for decoding or encoding Parameters medianame media to open mode (str) r (decoding) or w (encoding) quiet (bool) turn on/off libav or ffmpeg warnings addresampler(streamindex, inaudio, outaudio) Add an audio resampler A resampler is responsible for: resampling audio (frequency, layout) converting output data format (ie s16p -> s16) Parameters inaudio (dict) audio input info outaudio (dict) audio output info Note: each audio info requires the following fields: samplerate: sample rate samplefmt: sample format name (ie s16) layout (optional): channel layout (ie. mono, stereo...) channels (optional): channel count if layout is not specified, its value is guessed from the channel count addscaler(streamindex, width, height, pixelformat= rgb24, scaling= bilinear ) Add a scaler A scaler is responsible for: scaling a video converting output data format (ie yuv420p to rgb24) Parameters 6.3. avpy 13

streamindex (int) stream index with new stream width height (int) new stream height pixelformat (str) output pixel format scaling (str) scaling algorithm See also: https://en.wikipedia.org/wiki/image_scaling Note: Available scaling algorithm fast_bilinear bilinear bicubic area bicubiclin (bicubic for luma, bilinear for chroma) gauss sinc lanczos spline addstream(streamtype, streaminfo) Add a stream After opening a media for encoding (writing), a stream of desired type (video or audio) have to be added. Parameters streamtype (str) video or audio stream streaminfo (dict) stream parameters Supported stream parameters: video: audio: width, height: video size pixelformat: pixel format name (ie. rgb24, yuv420p...) codec: video codec name (ie. mp4), auto is a valid value timebase: as a tuple (ie (1, 25) for 25 fps) bitrate: average bit rate (ie 64000 for 64kbits/s) samplerate: sample frequency (ie. 44100 for 44.1 khz) bitrate: average bit rate (see video bit rate) channels channel count (ie. usually 2) 14 Chapter 6. Indices and tables

codec: audio codec name, auto is a valid value samplefmt: sample format (ie flt for float) More parameters are documented here: Encoding Note: For an image, timebase and bitrate parameters are ignored More parameters will be supported in the near futur Subtitle streams are not yet supported Note: use codecinfo() to query codec caps audiopacket() Get an audio packet ready for encoding purpose Initialize and allocate data for an audio packet. Data format will depend to the previously added stream. Returns video packet Return type Packet Raises RuntimeError if data could not be allocated info() Get media information Returns dict with the following fields: name, metadata, stream, duration Return type dict duration: media duration in seconds name: media filename stream: list of stream info (dict) Note: each stream info will contains the following fields: all: codec: codec short name type: video, audio or subtitle video: widht, height: video size fps: as a tuple of 3 values (num, den, ticks) pixelformat: pixel format name (ie. rgb24, yuv420p...) audio: samplerate: sample rate channels: channel count samplefmt: sample format name (ie. s16...) 6.3. avpy 15

samplefmtid: sample format id (internal use) framesize: frame size bytespersample: bytes for sample format (ie. 2 for s16) subtitle: subtitle header: header string See also: writeheader() metadata() Get media metadata Returns a dict with key, value = metadata key, metadata value Note: method is also called by info() See also: writeheader() next() Iterate over Media Return type Packet static open(*args, **kwds) Open a media file (writing only) Parameters medianame (str) media name mode (str) open media mode (ignored) buffering (int) buffering (ignored) metadata (dict) meta data dict (optional) streamsinfo (dict) stream(s) info videopacket() Get a video packet ready for encoding purpose Initialize and allocate data for a video packet. Data format will depend to the previously added stream. Returns video packet Return type Packet write(packet, pts, mediatype= video ) Write packet to media Parameters packet (Packet or array.array or numpy.array) packet to encode and add to media writeheader(metadata=none) Write media header Write media header. This method have to be called before any call to write() 16 Chapter 6. Indices and tables

Parameters metadata (dict) media metadata (ie. artist, year...) see http://multimedia.cx/eggs/supplying-ffmpeg-with-metadata/ for available metadata per con- Note: tainer writetrailer() Write media trailer Write media trailer. Call this method just before closing or deleting media. class avpy.avmedia.packet(formatctx) Bases: object Media data container When decoding a media, a packet object will be returned and might be decoded later. When encoding, a packet is retrieved then written. init (formatctx) addresampler(streamindex) Add an audio resampler Note: called by Media.addResampler() decode() Decode data streamindex() avpy.avmedia.averror(res) Return an error message from an error code The libav or ffmpeg functions can return an error code, this function will do its best to translate it to an human readable error message. Parameters res (int) error code Returns error message Return type str Note: if error is unknown, return Unknown error code %d avpy.avmedia.codecinfo(name, decode=true) Retrieve specific codec information Parameters name (bool) codec name decode codec decoder info. Set decode to False to get codec encoder info. Returns codec information Return type dict Raises ValueError if codec name is unknown 6.3. avpy 17

Note: codec information keys: name longname type: video, audio or subtitle thread: codec thread capacity autothread: auto thread support framerates: supported frame rates samplerates: supported sample rates pixfmts: supported pixel formats profiles: supported encoding profiles samplefmts: supported sample formats avpy.avmedia.codecs() Get all supported codecs Returns a dict with 3 keys (audio, video and subtitle). For each key, the value is a dict with 2 keys (encoding and decoding). Return type dict avpy.avmedia.formats() Get all supported formats Returns a dict with 2 keys: muxing and demuxing Return type dict avpy.avmedia.versions() Return version & config & license of C libav or ffmpeg libs Returns dict with keys: version, configuration, license, path Return type dict Module contents 6.3.2 Encoding Additional parameters gopsize: the number of pictures in a group of pictures, or 0 for intra_only http://en.wikipedia.org/wiki/group_of_pictures maxbframes: maximum number of B-frames between non-b-frames https://en.wikipedia.org/wiki/inter_frame mbdecision: 18 Chapter 6. Indices and tables

macroblock decision mode https://en.wikipedia.org/wiki/macroblock 6.4 Changelog 6.4.1 Changes in Version 0.1.2 Audio resampling support FFmpeg 2.5, 2.6, 2.7 and 2.8 support 6.4.2 Changes in Version 0.1.1 Add scaler arguments (pixel format, scaling algo) Python3 fixes 6.4.3 Changes in Version 0.1.0 Initial release 6.4. Changelog 19

20 Chapter 6. Indices and tables

Python Module Index a avpy, 18 avpy.av, 13 avpy.avmedia, 13 21

22 Python Module Index

Index Symbols init () (avpy.avmedia.media method), 13 init () (avpy.avmedia.packet method), 17 A addresampler() (avpy.avmedia.media method), 13 addresampler() (avpy.avmedia.packet method), 17 addscaler() (avpy.avmedia.media method), 13 addstream() (avpy.avmedia.media method), 14 audiopacket() (avpy.avmedia.media method), 15 averror() (in module avpy.avmedia), 17 avpy (module), 18 avpy.av (module), 13 avpy.avmedia (module), 13 C codecinfo() (in module avpy.avmedia), 17 codecs() (in module avpy.avmedia), 18 D decode() (avpy.avmedia.packet method), 17 F formats() (in module avpy.avmedia), 18 I info() (avpy.avmedia.media method), 15 M Media (class in avpy.avmedia), 13 metadata() (avpy.avmedia.media method), 16 N next() (avpy.avmedia.media method), 16 O open() (avpy.avmedia.media static method), 16 P Packet (class in avpy.avmedia), 17 S streamindex() (avpy.avmedia.packet method), 17 V versions() (in module avpy.avmedia), 18 videopacket() (avpy.avmedia.media method), 16 W write() (avpy.avmedia.media method), 16 writeheader() (avpy.avmedia.media method), 16 writetrailer() (avpy.avmedia.media method), 17 23