video-gif-previewer 0.1.1 → 0.1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08e35907ca5d95b4ce59a135cbe9572a1f13240df1c8abdfed340f3ada0fcb28'
4
- data.tar.gz: 34bc9c5bda01697d00d0d45d7679bf05fd1e26769e8cf4384c0b8d06a2e2342d
3
+ metadata.gz: b2b325311e19a74076204cc56dbfd8815c3e4c2cd6653045ff2e7da1e78f0fc4
4
+ data.tar.gz: ae351ad22913a542313c2bb94ebf2df684713cb23e48555bd0ff19831094388f
5
5
  SHA512:
6
- metadata.gz: 9427e2a3edad7c1140e8d00b85c8205cde639167a5316748e2d32a9d10a89a5511ceeae8cabcbe6641833bc2eb08b089aa8ae7e842273111f4896a33089c018d
7
- data.tar.gz: deafe286cb4ff483b60287fd9898eed29cefff1659b64df98abfc262cf01d894c0fc58fb38c1154290b7d23094d0ebaaff3e8737438c4bf0259a629c7a1752fc
6
+ metadata.gz: 790563509871a5209c51a05e65aebc513d2c7067e1b80da6ad70a2cc26dc1ff0ca9b02c9c0280d0df5b2069dd8eaea3629cdb5efd3c65cbad92ca2fdc4c2efe3
7
+ data.tar.gz: 9c06563698db999a6d876c7d1175a08a475f7641d7889cae4aefc3fabac50268c2c142ff2e8d14145240d942a5a6cdcd3ebd98b79776f526a2083d40c5d41584
data/lib/gif_previewer.rb CHANGED
@@ -17,7 +17,12 @@ class GifPreviewer < ActiveStorage::Previewer::VideoPreviewer
17
17
  end
18
18
 
19
19
  rescue Timeout::Error
20
- Rails.logger.error(msg: "Timeout::Error, processing took too long", max_allowed_time: MAX_PROCESSING_TIME)
20
+ Rails.logger.error(
21
+ msg: "Timeout::Error, processing took too long",
22
+ max_allowed_time: MAX_PROCESSING_TIME,
23
+ record_type: @blob.attachments.first.record_type,
24
+ record_id: @blob.attachments.first.record.id,
25
+ )
21
26
 
22
27
  # If we take too long encoding a gif, fallback to the standard rails VideoPreviewer
23
28
  super
@@ -55,12 +60,16 @@ class GifPreviewer < ActiveStorage::Previewer::VideoPreviewer
55
60
  `#{ffprobe_path} -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 #{input_file.path}`.to_f.floor.to_i
56
61
  end
57
62
 
58
- # Use file_duration to either pick a random place ~33% into the file, or if the file is too short, use 0
59
63
  def start_frame(file_duration:)
60
- if file_duration > 10
64
+ if file_duration > 300
65
+ # if the file is fairly long (> 5m) start around ~1m into the file to avoid long processing
66
+ 60
67
+ elsif file_duration > 10
68
+ # if file is not super long, use file_duration to either pick a random place ~33% into the file
61
69
  mid_frame = (file_duration.to_f / 3).floor
62
70
  mid_frame > 3 ? mid_frame : 3
63
71
  else
72
+ # if the file is too short, just start from 0
64
73
  0
65
74
  end
66
75
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class VideoGifPreviewer
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: video-gif-previewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Haberer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-15 00:00:00.000000000 Z
11
+ date: 2025-05-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generate rails active storage video previews as gifs
14
14
  email: bhaberer@gmail.com
@@ -25,7 +25,6 @@ licenses:
25
25
  - GPL-2.0-only
26
26
  metadata:
27
27
  allowed_push_host: https://rubygems.org/
28
- homepage_uri: https://github.com/bhaberer/video-gif-previewer
29
28
  source_code_uri: https://github.com/bhaberer/video-gif-previewer
30
29
  rubygems_mfa_required: 'true'
31
30
  post_install_message:
@@ -43,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
42
  - !ruby/object:Gem::Version
44
43
  version: '0'
45
44
  requirements: []
46
- rubygems_version: 3.5.11
45
+ rubygems_version: 3.5.23
47
46
  signing_key:
48
47
  specification_version: 4
49
48
  summary: ActiveStorage Gif Video Preview generation