carrierwave_streamio_ffmpeg 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -8
- data/lib/carrierwave_streamio_ffmpeg/options.rb +32 -4
- data/lib/carrierwave_streamio_ffmpeg/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fb7937b295b87f4de6de375b39e6200de244491
|
4
|
+
data.tar.gz: 5b33e5a11a79b43563baf1760479e537025bae4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6717392774d8330f5bbf1b417e901f30e0d0e78f69798162fed43308554984960f1cf01673aebd1321bc2bb444ae3620d01c0a6651c2e21f524548350b645a3
|
7
|
+
data.tar.gz: b9539990366b7efe4573bc7bdcef2804715ffd48ffbc79abc2daad79b30aa99606ddeffe15c7b4cc6909953eb34c0d84b1c75acedbd73fcf7bc065eb7c2c96df
|
data/README.md
CHANGED
@@ -20,14 +20,25 @@ Or install it yourself as:
|
|
20
20
|
In the Rails app/uploaders/filename.rb, call the encode function with options.
|
21
21
|
Example :
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
class VideoUploader < CarrierWave::Uploader::Base
|
24
|
+
include CarrierWave::Video
|
25
|
+
include CarrierwaveStreamioFfmpeg
|
26
|
+
|
27
|
+
storage :file
|
28
|
+
|
29
|
+
def store_dir
|
30
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
31
|
+
end
|
32
|
+
|
33
|
+
version :mp4 do
|
34
|
+
version :p480 do
|
35
|
+
process encode: [{format: :mp4, resolution: :p480, quality: :med, preserve_aspect_ratio: :width}]
|
36
|
+
end
|
37
|
+
|
38
|
+
def full_filename(for_file)
|
39
|
+
super.chomp(File.extname(super)) + '.mp4'
|
40
|
+
end
|
41
|
+
end
|
31
42
|
end
|
32
43
|
|
33
44
|
The options are passed as hash to this function, can be also empty.
|
@@ -3,14 +3,42 @@ module CarrierwaveStreamioFfmpeg
|
|
3
3
|
|
4
4
|
def video_options(file, opts = {})
|
5
5
|
opts[:resolution] = set_file_resolution(opts, file)
|
6
|
-
opts[:video_bitrate] =
|
7
|
-
opts[:
|
6
|
+
opts[:video_bitrate] = set_video_quality(opts, file)
|
7
|
+
opts[:frame_rate] = set_video_frames(opts, file)
|
8
|
+
opts[:audio_bitrate] = set_audio_quality(opts, file)
|
9
|
+
opts[:threads] = 8
|
8
10
|
format = opts[:format]
|
9
11
|
opts = opts.except(:quality, :preserve_aspect_ratio, :format)
|
10
12
|
opts.merge!(codec(format))
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
15
|
+
def set_video_frames(opts, file)
|
16
|
+
case opts[:quality]
|
17
|
+
when :low
|
18
|
+
25
|
19
|
+
when :med
|
20
|
+
30
|
21
|
+
when :high
|
22
|
+
60
|
23
|
+
else
|
24
|
+
file.frame_rate
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_audio_quality(opts, file)
|
29
|
+
case opts[:quality]
|
30
|
+
when :low
|
31
|
+
96
|
32
|
+
when :med
|
33
|
+
128
|
34
|
+
when :high
|
35
|
+
256
|
36
|
+
else
|
37
|
+
(file.audio_bitrate)/100
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_video_quality(opts, file)
|
14
42
|
case opts[:quality]
|
15
43
|
when :low
|
16
44
|
1250
|
@@ -19,7 +47,7 @@ module CarrierwaveStreamioFfmpeg
|
|
19
47
|
when :high
|
20
48
|
15000
|
21
49
|
else
|
22
|
-
(file.
|
50
|
+
(file.video_bitrate)/100
|
23
51
|
end
|
24
52
|
end
|
25
53
|
|