comparison libervia/backend/tools/video.py @ 4270:0d7bb4df2343

Reformatted code base using black.
author Goffi <goffi@goffi.org>
date Wed, 19 Jun 2024 18:44:57 +0200
parents 4b842c1fb686
children
comparison
equal deleted inserted replaced
4269:64a85ce8be70 4270:0d7bb4df2343
27 27
28 28
29 log = getLogger(__name__) 29 log = getLogger(__name__)
30 30
31 31
32
33
34
35 try: 32 try:
36 ffmpeg_path = which('ffmpeg')[0] 33 ffmpeg_path = which("ffmpeg")[0]
37 except IndexError: 34 except IndexError:
38 log.warning(_( 35 log.warning(_("ffmpeg executable not found, video thumbnails won't be available"))
39 "ffmpeg executable not found, video thumbnails won't be available"))
40 ffmpeg_path = None 36 ffmpeg_path = None
41 37
42 38
43 async def get_thumbnail(video_path: Union[Path, str], dest_path: Path) -> Path: 39 async def get_thumbnail(video_path: Union[Path, str], dest_path: Path) -> Path:
44 """Extract thumbnail from video 40 """Extract thumbnail from video
51 Image will be in JPEG format. 47 Image will be in JPEG format.
52 @raise exceptions.NotFound: ffmpeg is missing 48 @raise exceptions.NotFound: ffmpeg is missing
53 """ 49 """
54 if ffmpeg_path is None: 50 if ffmpeg_path is None:
55 raise exceptions.NotFound( 51 raise exceptions.NotFound(
56 _("ffmpeg executable is not available, can't generate video thumbnail")) 52 _("ffmpeg executable is not available, can't generate video thumbnail")
53 )
57 54
58 await async_process.run( 55 await async_process.run(
59 ffmpeg_path, "-i", str(video_path), "-ss", "10", "-frames:v", "1", str(dest_path) 56 ffmpeg_path, "-i", str(video_path), "-ss", "10", "-frames:v", "1", str(dest_path)
60 ) 57 )