mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-08-07 18:39:47 +08:00
Detect: Improve handling of undetected platforms
This commit is contained in:
parent
79b19eba72
commit
3ba9598c19
@ -60,12 +60,22 @@ def detect_gpu():
|
|||||||
Detect the GPU vendor, generation and model if possible.
|
Detect the GPU vendor, generation and model if possible.
|
||||||
"""
|
"""
|
||||||
plat_sys = platform.system()
|
plat_sys = platform.system()
|
||||||
|
gpu = None
|
||||||
|
|
||||||
if plat_sys == 'Linux':
|
if plat_sys == 'Linux':
|
||||||
# TODO: Android and other Linux'es that don't have `lshw`
|
# TODO: Android and other Linux'es that don't have `lshw`
|
||||||
display_output = subprocess.check_output(
|
display_output = subprocess.check_output(
|
||||||
['lshw', '-class', 'display', '-json'])
|
['lshw', '-class', 'display', '-json'])
|
||||||
return json.loads(display_output.decode().strip().strip(','))
|
display_data = json.loads(display_output.decode().strip().strip(','))
|
||||||
# TODO Other platforms
|
gpu = dict(
|
||||||
|
vendor=display_data['vendor'].replace(' Corporation', ''))
|
||||||
|
|
||||||
|
else:
|
||||||
|
# TODO Other platforms
|
||||||
|
raise NotImplementedError(
|
||||||
|
'GPU detection for {0!r} not supported yet'.format(plat_sys))
|
||||||
|
|
||||||
|
return gpu
|
||||||
|
|
||||||
|
|
||||||
def detect_hwaccels(hwaccels=None, cmd='ffmpeg'):
|
def detect_hwaccels(hwaccels=None, cmd='ffmpeg'):
|
||||||
@ -87,8 +97,7 @@ def detect_hwaccels(hwaccels=None, cmd='ffmpeg'):
|
|||||||
data = _get_data()
|
data = _get_data()
|
||||||
plat_sys = platform.system()
|
plat_sys = platform.system()
|
||||||
gpu = detect_gpu()
|
gpu = detect_gpu()
|
||||||
api_avail = data['hwaccels']['api_avail'][plat_sys][
|
api_avail = data['hwaccels']['api_avail'][plat_sys][gpu['vendor']]
|
||||||
gpu['vendor'].replace(' Corporation', '')]
|
|
||||||
hwaccels = [
|
hwaccels = [
|
||||||
hwaccel for hwaccel in hwaccels if hwaccel['name'] in api_avail]
|
hwaccel for hwaccel in hwaccels if hwaccel['name'] in api_avail]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user