| 45 | return x |
| 46 | |
| 47 | async 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 |