carrierwave_streamio_ffmpeg 0.1.1 → 0.2.0

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
  SHA1:
3
- metadata.gz: deac9ce91cdbdedc487ee1a907940bdb6dba5b78
4
- data.tar.gz: 9363d1c04c28012f01b961d906259dbdb64e8549
3
+ metadata.gz: 4fb7937b295b87f4de6de375b39e6200de244491
4
+ data.tar.gz: 5b33e5a11a79b43563baf1760479e537025bae4a
5
5
  SHA512:
6
- metadata.gz: d331d055ca880165a314357ee1fb2e0c4eca5cbbde0bc40d83e5208fe435fcc165bbd83b1b7b790f50beb2b24c9cbd095d534e6c15dd872db609a6fcde625c78
7
- data.tar.gz: '08ad028fd61f2062a9f6cec356b120554750e34f4c16bbad651f9921667423c7e15536811c9d208940b87d14ead2990c2117b693c4449c86d4036f9677c228e2'
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
- version :mp4 do
24
- version :p480 do
25
- process encode: [{format :mp4, resolution: :p480, quality: :low, preserve_aspect_ratio: :width}]
26
- end
27
-
28
- def full_filename(for_file)
29
- super.chomp(File.extname(super)) + '.mp4'
30
- end
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] = set_file_quality(opts, file)
7
- opts[:threads] = 4
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 set_file_quality(opts, file)
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.bitrate)/1024
50
+ (file.video_bitrate)/100
23
51
  end
24
52
  end
25
53
 
@@ -1,3 +1,3 @@
1
1
  module CarrierwaveStreamioFfmpeg
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave_streamio_ffmpeg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ssooraj