mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
fix(video): return none when the av package is unavailable
check_av returned the module on success and False on failure, so the two callers testing for None treated a failed import as a working av and reached into it anyway. It now returns None, and the guard that had to test for both tests for one.
This commit is contained in:
@@ -205,7 +205,7 @@ def atomic_save_video(
|
||||
if metadata is None:
|
||||
metadata = {}
|
||||
av = check_av()
|
||||
if av is None or av is False:
|
||||
if av is None:
|
||||
log.error('Video: ffmpeg/av not available')
|
||||
return
|
||||
savejob = shared.state.begin('Save video')
|
||||
|
||||
@@ -54,13 +54,14 @@ def supports_last_frame(model):
|
||||
|
||||
|
||||
def check_av():
|
||||
"""The av module, or None when it is unavailable; callers guard on the None."""
|
||||
install('av')
|
||||
try:
|
||||
import av
|
||||
av.logging.set_level(av.logging.ERROR) # pylint: disable=c-extension-no-member
|
||||
except Exception as e:
|
||||
log.error(f'av package: {e}')
|
||||
return False
|
||||
return None
|
||||
return av
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user