memcom
Interprocess real time message/audio/video buffers
Table of contents
Install
$ pip3 install memcom
Examples
Example that creates a test clip
import os
import time
import asyncio
import memcom
def on_error(ctx, e):
print(ctx.getName(), '---', e)
async def run():
print(memcom.__info__)
# Video file name
if not os.path.isdir('./out'):
os.mkdir('./out')
fname = './out/testvid.avi'
# Clip length in seconds
t = 30
# Time divider / Clip will be t / div seconds in length
# Using a higher divider gives more time to process
# If your CPU can´t keep up, increase this value
div = 1
#---------------------------------------------------------------
# Video parameters
w = 800
h = 600
vfps = 15
print('Create video share')
vid = memcom.mcVideo()
if not vid.create(bufs=2*vfps, width=w, height=h, fps=vfps, cleanup=True):
raise Exception(vid.getError())
vsname = vid.getName()
print(f'Video share created: {vsname}')
#---------------------------------------------------------------
# Audio Parameters
ch = 2
bps = 16
asr = 48000
afps = 50
print('Create audio share')
aud = memcom.mcAudio()
if not aud.create(bufs=2*afps, ch=ch, bps=bps, bitrate=asr, fps=afps, cleanup=True):
raise Exception(aud.getError())
asname = aud.getName()
print(f'Audio share created: {asname}')
#---------------------------------------------------------------
# Create initial rectangles
# Initial rects
n = 0
# Target number of rects / adds one each second
m = 4
tv = []
rects = [{'x': 0, 'y': 0, 'w': w, 'h': h}]
for i in range(0, n-1):
memcom.addRect(rects)
ri = 0
for r in rects:
ri += 1
v = memcom.mcTestVid(on_error=on_error,
opts={'name': f'Rect{ri}', 'roi':r,
'video':vsname, 'vbias':-0.25, 'vwin':0.25,
'audio':asname, 'abias':-0.25, 'awin':0.25})
if not v.create():
raise Exception(v.getError())
tv.append(v)
#---------------------------------------------------------------
# Create file recorder
print('Create recorder')
rec = memcom.mcRecord(on_error=on_error,
opts={'name': 'Recorder',
'video':vsname, 'vbias':-0.5, 'vwin':0.25,
'audio':asname, 'abias':-0.5, 'awin':0.25})
if not rec.create(fname):
# if not rec.create(fname, opts={'roi':{'x':int(w/4), 'y':int(h/4), 'w':int(w/2), 'h':int(h/2)}}):
raise Exception(rec.getError())
#---------------------------------------------------------------
# Create frame eraser / clears frames before reuse
print('Create Eraser')
erase = memcom.mcBlank(on_error=on_error,
opts={'name': 'Eraser',
'video':vsname, 'vbias':-0.75, 'vwin':0.25,
'audio':asname, 'abias':-0.75, 'awin':0.25})
if not erase.create():
raise Exception(rec.getError())
#---------------------------------------------------------------
# Create the clock
print('Create clock')
clk = memcom.mcClock(on_error=on_error,
opts={'name': 'Clock', 'div':div,
'video':vsname, 'vfps':vfps, 'vbias':0, 'vwin':0.25,
'audio':asname, 'afps':afps, 'abias':0, 'awin':0.25})
clk.create()
#---------------------------------------------------------------
# Run everything for t * div seconds
d = 0
c = 0
t = t * div
while 0 < t:
time.sleep(1)
t -= 1
d += 1
if d >= div:
d = 0
c += 1
if c >= 4:
c = 0
if len(rects) < m:
print('Add rect')
r = memcom.addRect(rects)
ri = len(rects) + 1
v = memcom.mcTestVid(on_error=on_error,
opts={'name': f'Rect{ri}', 'roi':r,
'video':vsname, 'vbias':-0.25, 'vwin':0.25,
'audio':asname, 'abias':-0.25, 'awin':0.25})
if not v.create():
raise Exception(v.getError())
tv.append(v)
# Close everything
clk.close()
erase.close()
rec.close()
for v in tv:
v.close()
vid.close()
if __name__ == '__main__':
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(run())
References
Metadata
Release files for memcom 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| memcom-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for memcom-0.1.1-py3-none-any.whl |
Release files / memcom-0.1.1-py3-none-any.whl
| Download URL | memcom-0.1.1-py3-none-any.whl |
|---|---|
| Size | 24.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
617e92316390dd864e4b8d8c22b212887ead23368b492138877d7b97b8d457c2
|
|
BLAKE2b-256 checksum How to use checksums |
ea3f0d25b8a10e25c1fdb1b076b38174e7563309e8afda33f572d95829cc3827
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for memcom 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.