carrierwave-audio 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/carrierwave/audio/version.rb +1 -1
- data/lib/carrierwave/audio.rb +7 -7
- 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: 8c9b7615a28c346d73cd16017f9943d4477b560d
|
4
|
+
data.tar.gz: ddd8e120252b8c032727e568f3d6fcaf6bbd4c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b5d82802d447ece58bd1260ed2bc538b130d19882132886975649dfb0d5d069f4b9a3db9ee77d8367141947935584908d6597bdc32567403d998c20502f6e22
|
7
|
+
data.tar.gz: 74ff970538d3d380daf2fba2244e66002bfd10d1639636b86b49889d552c3dedd0f9825795ad642b68c047215eb2ce3e9a82e24ac94d2d0d6432d5c2585b7f29
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
Include CarrierWave::Audio into your CarrierWave uploader class:
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
class
|
24
|
+
class AudioUploader < CarrierWave::Uploader::Base
|
25
25
|
include CarrierWave::Audio
|
26
26
|
end
|
27
27
|
```
|
@@ -81,7 +81,9 @@ If you'd like to add a watermark over the top of your file, use `watermark` like
|
|
81
81
|
process :watermark => [watermark_file_path, output_format, output_options]
|
82
82
|
```
|
83
83
|
|
84
|
-
`watermark_file_path` - REQUIRED. Path to where your watermarked file is stored
|
84
|
+
`watermark_file_path` - REQUIRED. Path to where your watermarked file is stored.
|
85
|
+
|
86
|
+
VERY IMPORTANT: The watermarked file must be a 44.1k, 2-channel mp3. It needs to be a long file. It'll be concatenated to fit the length of your uploaded file.
|
85
87
|
|
86
88
|
`output_format` - Optional. The only currently available option is the default, `:mp3`.
|
87
89
|
|
data/lib/carrierwave/audio.rb
CHANGED
@@ -37,16 +37,16 @@ module CarrierWave
|
|
37
37
|
|
38
38
|
# Normalize file to -6dB
|
39
39
|
normalized_tmp_path = File.join File.dirname(current_path), "tmp_norm_#{current_filename_without_extension}_#{Time.current.to_i}.#{input_options[:type]}"
|
40
|
-
convert_file(current_path, input_options, normalized_tmp_path, input_options, { gain: "-n -6" })
|
40
|
+
convert_file(current_path, input_options, normalized_tmp_path, default_output_options(input_options[:type]), { gain: "-n -6" })
|
41
41
|
|
42
42
|
# Combine normalized file and watermark, normalizing final product to 0dB
|
43
43
|
final_tmp_path = File.join File.dirname(current_path), "tmp_wtmk_#{current_filename_without_extension}_#{Time.current.to_i}.#{format}"
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
combiner = Sox::Cmd.new(combine: :mix)
|
45
|
+
combiner.add_input normalized_tmp_path, input_options
|
46
|
+
combiner.add_input watermark_file_path, watermark_options
|
47
|
+
combiner.set_output final_tmp_path, default_output_options(format).merge(output_options)
|
48
|
+
combiner.set_effects({ trim: "0 #{Soxi::Wrapper.file(current_path).seconds}", gain: "-n" })
|
49
|
+
combiner.run
|
50
50
|
File.rename final_tmp_path, current_path
|
51
51
|
set_content_type format
|
52
52
|
end
|