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:
CalamitousFelicitousness
2026-08-18 00:54:46 +01:00
parent 05574bc30a
commit 8774cc72b9
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -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')
+2 -1
View File
@@ -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