-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathffprobe.py
41 lines (33 loc) · 863 Bytes
/
ffprobe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# GOAL:
# getting track for logging
import logging
LOGGER = logging.getLogger(__name__)
# GOAL:
# create ffprobe handler
import asyncio
from os import path as os_path
from json import loads as json_loads
async def stream_creator(filepath):
if not os_path.isfile(filepath):
return False
cmd = [
"ffprobe",
"-v",
"quiet",
"-print_format",
'json',
"-show_format",
'-show_streams',
filepath
]
LOGGER.debug(cmd)
process = await asyncio.create_subprocess_exec(
*cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await process.communicate()
LOGGER.debug("[stdout] " + stdout.decode())
LOGGER.debug("[stderr] " + stderr.decode())
info = json_loads(stdout.decode())
return info