https://github.com/flier/pyvpx
Python Binding of WebM VP8 Codec
https://github.com/flier/pyvpx
Last synced: over 1 year ago
JSON representation
Python Binding of WebM VP8 Codec
- Host: GitHub
- URL: https://github.com/flier/pyvpx
- Owner: flier
- Created: 2011-12-05T03:11:44.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-12-22T14:52:17.000Z (over 14 years ago)
- Last Synced: 2025-03-24T07:13:53.596Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 137 KB
- Stars: 8
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
PyVPX is a Python Binding of the WebM VP8 Codec, it supports encode or decode a sequence of video frames
You could use a Encoder instance to encode a Image object, the image format should be vpx.VPX_IMG_FMT_I420 or vpx.VPX_IMG_FMT_YV12.
frame_count = 1
with Encoder(320, 240) as encoder:
with Image(320, 240) as img:
img.clear()
# fetch and fill the image data buffer
for kind, packet in encoder.encode(img, frame_count):
if kind == vpx.VPX_CODEC_CX_FRAME_PKT:
print "sent a frame packet with %d bytes" % len(packet)
frame_count += 1
You could use a Decoder instance to decode a sequence of packets for the video frames.
data = ... # fetch the packet (readable buffer object or string)
with Decoder() as decoder:
for img in decoder.decode(data):
print "received a %dx%d frame with %d bytes" % (img.width, img.height, len(img.data))
please check the unit test or for more detail.