|
32 | 32 | from pathlib import Path |
33 | 33 | from constrict.shared import get_tmp_dir, update_ui |
34 | 34 | from constrict.constrict_utils import get_encode_settings, get_resolution, get_framerate, get_duration, get_audio_bitrate |
35 | | -from constrict.enums import SourceState, Thumbnailer |
| 35 | +from constrict.enums import SourceState |
36 | 36 | from constrict.progress_pie import ProgressPie |
37 | 37 | from constrict.attempt_fail_box import AttemptFailBox |
38 | 38 | from constrict.progress_popover_box import ProgressPopoverBox |
@@ -377,59 +377,30 @@ def set_thumbnail(self, file_hash: int, daemon: bool) -> None: |
377 | 377 | this row represents, and storing it named with the video's file hash |
378 | 378 | in a temp directory |
379 | 379 | """ |
380 | | - bin_totem = 'totem-video-thumbnailer' |
381 | | - bin_ffmpeg = 'ffmpegthumbnailer' |
382 | | - |
| 380 | + bin_gst_thumbnailer = 'gst-video-thumbnailer' |
383 | 381 | generic_icon = 'image-x-generic' if self.mime_type == 'image/gif' else 'video-x-generic' |
384 | 382 |
|
385 | | - # Check Totem thumbnailer is installed. |
386 | | - # Use FFMPEG thumbnailer as a fallback. |
387 | | - # Use video-x-generic icon as the fallback's fallback. |
388 | | - |
389 | | - totem_exists = GLib.find_program_in_path(bin_totem) |
390 | | - thumbnailer = Thumbnailer.TOTEM |
| 383 | + gst_thumbnailer_exists = GLib.find_program_in_path(bin_gst_thumbnailer) |
391 | 384 |
|
392 | | - if not totem_exists: |
393 | | - ffmpeg_exists = GLib.find_program_in_path(bin_ffmpeg) |
394 | | - thumbnailer = Thumbnailer.FFMPEG |
395 | | - |
396 | | - if not ffmpeg_exists: |
397 | | - update_ui( |
398 | | - self.thumbnail.set_from_icon_name, |
399 | | - generic_icon, |
400 | | - daemon |
401 | | - ) |
402 | | - return |
| 385 | + if not gst_thumbnailer_exists: |
| 386 | + update_ui(self.thumbnail.set_from_icon_name, generic_icon, daemon) |
| 387 | + return |
403 | 388 |
|
404 | 389 | # Check tmp directory is available to write. |
405 | 390 | tmp_dir = get_tmp_dir() |
406 | 391 |
|
407 | 392 | if not tmp_dir: |
408 | | - update_ui( |
409 | | - self.thumbnail.set_from_icon_name, |
410 | | - generic_icon, |
411 | | - daemon |
412 | | - ) |
| 393 | + update_ui(self.thumbnail.set_from_icon_name, generic_icon, daemon) |
413 | 394 | return |
414 | 395 |
|
415 | 396 | thumb_filepath = str(tmp_dir / f'{file_hash}.jpg') |
416 | 397 |
|
417 | | - if thumbnailer == Thumbnailer.TOTEM: |
418 | | - subprocess.run([ |
419 | | - bin_totem, |
420 | | - self.video_path, |
421 | | - thumb_filepath |
422 | | - ]) |
423 | | - elif thumbnailer == Thumbnailer.FFMPEG: |
424 | | - subprocess.run([ |
425 | | - bin_ffmpeg, |
426 | | - '-i', |
427 | | - self.video_path, |
428 | | - '-o', |
429 | | - thumb_filepath |
430 | | - ]) |
431 | | - else: |
432 | | - raise Exception('Unknown thumbnailer set. Whoopsie daisies.') |
| 398 | + subprocess.run([ |
| 399 | + bin_gst_thumbnailer, |
| 400 | + '-p', self.video_path, |
| 401 | + '-s', '128', |
| 402 | + '-o', thumb_filepath |
| 403 | + ]) |
433 | 404 |
|
434 | 405 | thumb_file = Gio.File.new_for_path(thumb_filepath) |
435 | 406 |
|
|
0 commit comments