dragonfly_video 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +25 -0
- data/CHANGELOG.md +8 -0
- data/README.md +16 -0
- data/lib/dragonfly_video/plugin.rb +2 -0
- data/lib/dragonfly_video/processors/optimize.rb +51 -0
- data/lib/dragonfly_video/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 886d29837119e7414795e1d16c2bbc8e0b020c0a59d3f0f03e287f37e694a76e
|
4
|
+
data.tar.gz: dc12f2e5ec9f484da4d7e8067fa6e76f312e138ab13a280eb93834dc4030eee7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bedc5845d418641c73cb59d54104b2356216704f35f210281052e157eb2cabb1348285ad62debec70e3be639d3ce4dc704599341a55bb1a088e0287c23b8d16
|
7
|
+
data.tar.gz: 0c8653b452f6905802132f12f48417203a895610df17523e0a8c08f2f2c8e62fc9667d7d95bec7ae163b3dde020e4f998d1d85ed1a7018e99bd74d2f8883c64d
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: Test
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
branches: ["master"]
|
5
|
+
push:
|
6
|
+
branches: ["master"]
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby: ['2.1', '3.2', '3.3']
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v4
|
15
|
+
- name: Install dependencies
|
16
|
+
run: |
|
17
|
+
sudo apt-get clean
|
18
|
+
sudo apt-get update
|
19
|
+
sudo apt-get install -y ffmpeg
|
20
|
+
- uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
bundler-cache: true
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -74,6 +74,22 @@ Generates a screenshot of the video's first frame:
|
|
74
74
|
video.screenshot
|
75
75
|
```
|
76
76
|
|
77
|
+
### `remove_audio`
|
78
|
+
|
79
|
+
Removes audio from the video:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
video.remove_audio
|
83
|
+
```
|
84
|
+
|
85
|
+
### `optimize`
|
86
|
+
|
87
|
+
Optimizes the video based on predefined profiles: `:streaming`, `:archive`, `:mobile` or `:default`
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
video.optimize
|
91
|
+
```
|
92
|
+
|
77
93
|
## Contributing
|
78
94
|
|
79
95
|
1. Fork it ( https://github.com/asgerb/dragonfly_video/fork )
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "dragonfly_video/analysers/video_properties"
|
2
2
|
require "dragonfly_video/processors/screenshot"
|
3
3
|
require "dragonfly_video/processors/remove_audio"
|
4
|
+
require "dragonfly_video/processors/optimize"
|
4
5
|
|
5
6
|
class DragonflyVideo::Plugin
|
6
7
|
def call(app, _opts = {})
|
@@ -16,6 +17,7 @@ class DragonflyVideo::Plugin
|
|
16
17
|
|
17
18
|
app.add_processor :screenshot, DragonflyVideo::Processors::Screenshot.new
|
18
19
|
app.add_processor :remove_audio, DragonflyVideo::Processors::RemoveAudio.new
|
20
|
+
app.add_processor :optimize, DragonflyVideo::Processors::Optimize.new
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative "base_processor"
|
2
|
+
|
3
|
+
module DragonflyVideo
|
4
|
+
module Processors
|
5
|
+
class Optimize < BaseProcessor
|
6
|
+
def call(content, options = {})
|
7
|
+
raise "optimize only supports mp4" unless content.ext == "mp4"
|
8
|
+
|
9
|
+
profile = options.fetch(:profile, :default).to_sym
|
10
|
+
|
11
|
+
case profile
|
12
|
+
when :streaming
|
13
|
+
crf = 26
|
14
|
+
maxrate = "4000k"
|
15
|
+
bufsize = "8000k"
|
16
|
+
gop = 96
|
17
|
+
profile_v = "main"
|
18
|
+
preset = "fast"
|
19
|
+
when :archive
|
20
|
+
crf = 18
|
21
|
+
maxrate = nil
|
22
|
+
bufsize = nil
|
23
|
+
gop = nil
|
24
|
+
profile_v = "high"
|
25
|
+
preset = "slow"
|
26
|
+
when :mobile
|
27
|
+
crf = 28
|
28
|
+
maxrate = "1500k"
|
29
|
+
bufsize = "3000k"
|
30
|
+
gop = 48
|
31
|
+
profile_v = "baseline"
|
32
|
+
preset = "fast"
|
33
|
+
else # Default
|
34
|
+
crf = 24
|
35
|
+
maxrate = nil
|
36
|
+
bufsize = nil
|
37
|
+
gop = nil
|
38
|
+
profile_v = "main"
|
39
|
+
preset = "medium"
|
40
|
+
end
|
41
|
+
|
42
|
+
maxrate_option = maxrate ? "-maxrate #{maxrate} -bufsize #{bufsize}" : ""
|
43
|
+
gop_option = gop ? "-g #{gop}" : ""
|
44
|
+
|
45
|
+
content.shell_update do |old_path, new_path|
|
46
|
+
"#{FFMPEG_COMMAND} -y -i #{old_path} #{gop_option} -map_metadata -1 -c:a aac -c:v libx264 -crf #{crf} -preset #{preset} -profile:v #{profile_v} -pix_fmt yuv420p -movflags +faststart -vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2' #{maxrate_option} #{new_path}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragonfly_video
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asger Behncke Jacobsen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|
@@ -115,6 +115,7 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
+
- ".github/workflows/test.yml"
|
118
119
|
- ".gitignore"
|
119
120
|
- ".travis.yml"
|
120
121
|
- CHANGELOG.md
|
@@ -130,6 +131,7 @@ files:
|
|
130
131
|
- lib/dragonfly_video/analysers/video_properties.rb
|
131
132
|
- lib/dragonfly_video/plugin.rb
|
132
133
|
- lib/dragonfly_video/processors/base_processor.rb
|
134
|
+
- lib/dragonfly_video/processors/optimize.rb
|
133
135
|
- lib/dragonfly_video/processors/remove_audio.rb
|
134
136
|
- lib/dragonfly_video/processors/screenshot.rb
|
135
137
|
- lib/dragonfly_video/version.rb
|