MCPcopy Index your code
hub / github.com/vasusen-code/SaveRestrictedContentBot / screenshot

Function screenshot

main/plugins/helpers.py:47–73  ·  view source on GitHub ↗
(video, duration, sender)

Source from the content-addressed store, hash-verified

45 return x
46
47async def screenshot(video, duration, sender):
48 if os.path.exists(f'{sender}.jpg'):
49 return f'{sender}.jpg'
50 time_stamp = hhmmss(int(duration)/2)
51 out = dt.now().isoformat("_", "seconds") + ".jpg"
52 cmd = ["ffmpeg",
53 "-ss",
54 f"{time_stamp}",
55 "-i",
56 f"{video}",
57 "-frames:v",
58 "1",
59 f"{out}",
60 "-y"
61 ]
62 process = await asyncio.create_subprocess_exec(
63 *cmd,
64 stdout=asyncio.subprocess.PIPE,
65 stderr=asyncio.subprocess.PIPE
66 )
67 stdout, stderr = await process.communicate()
68 x = stderr.decode().strip()
69 y = stdout.decode().strip()
70 if os.path.isfile(out):
71 return out
72 else:
73 None

Callers 1

get_msgFunction · 0.90

Calls 1

hhmmssFunction · 0.85

Tested by

no test coverage detected