Skip to content

Commit a86679d

Browse files
committed
Merge branch 'gst_thumbnailer'
2 parents 694d357 + f047fdf commit a86679d

3 files changed

Lines changed: 20 additions & 64 deletions

File tree

io.github.wartybix.Constrict.Devel.json

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"--socket=wayland",
1313
"--require-version=1.14.5"
1414
],
15+
"build-options" : {
16+
"append-path" : "/usr/lib/sdk/rust-stable/bin",
17+
"build-args": ["--share=network"]
18+
},
1519
"cleanup-commands" : [
1620
"mkdir -p ${FLATPAK_DEST}/lib/ffmpeg"
1721
],
@@ -40,29 +44,14 @@
4044
]
4145
},
4246
{
43-
"name" : "totem-pl-parser",
47+
"name" : "gst-thumbnailers",
4448
"builddir" : true,
4549
"buildsystem" : "meson",
4650
"sources" : [
4751
{
4852
"type" : "archive",
49-
"url" : "https://gitlab.gnome.org/GNOME/totem-pl-parser/-/archive/V_3_26_6/totem-pl-parser-V_3_26_6.tar.gz",
50-
"mirror-urls" : [
51-
"https://github.com/GNOME/totem-pl-parser/archive/refs/tags/V_3_26_6.tar.gz"
52-
],
53-
"sha256" : "7219272a4863f823e2dd6d997e78d725de9e6071b1af1b478870f207731a8234"
54-
}
55-
]
56-
},
57-
{
58-
"name" : "totem-video-thumbnailer",
59-
"builddir" : true,
60-
"buildsystem" : "meson",
61-
"sources" : [
62-
{
63-
"type" : "git",
64-
"url" : "https://gitlab.gnome.org/GNOME/totem-video-thumbnailer.git",
65-
"commit" : "6cb399918571a97591ff5a4a5a41d8e46b11027a"
53+
"url" : "https://gitlab.gnome.org/GNOME/gst-thumbnailers/-/archive/1.0.alpha.1/gst-thumbnailers-1.0.alpha.1.tar.gz",
54+
"sha256" : "a754bc1a21522a5315463b05fb4d3f02e7b824816b155c1826c77de8afe70e49"
6655
}
6756
]
6857
},

src/enums.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,3 @@ class SourceState:
4141
INCOMPATIBLE = 5
4242
WARN = 6
4343

44-
45-
class Thumbnailer:
46-
TOTEM = 0
47-
FFMPEG = 1

src/sources_row.py

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from pathlib import Path
3333
from constrict.shared import get_tmp_dir, update_ui
3434
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
3636
from constrict.progress_pie import ProgressPie
3737
from constrict.attempt_fail_box import AttemptFailBox
3838
from constrict.progress_popover_box import ProgressPopoverBox
@@ -377,59 +377,30 @@ def set_thumbnail(self, file_hash: int, daemon: bool) -> None:
377377
this row represents, and storing it named with the video's file hash
378378
in a temp directory
379379
"""
380-
bin_totem = 'totem-video-thumbnailer'
381-
bin_ffmpeg = 'ffmpegthumbnailer'
382-
380+
bin_gst_thumbnailer = 'gst-video-thumbnailer'
383381
generic_icon = 'image-x-generic' if self.mime_type == 'image/gif' else 'video-x-generic'
384382

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)
391384

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
403388

404389
# Check tmp directory is available to write.
405390
tmp_dir = get_tmp_dir()
406391

407392
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)
413394
return
414395

415396
thumb_filepath = str(tmp_dir / f'{file_hash}.jpg')
416397

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+
])
433404

434405
thumb_file = Gio.File.new_for_path(thumb_filepath)
435406

0 commit comments

Comments
 (0)