carrierwave-ffmpeg 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb0ebb5e6b8e14c45f648820ec84c548831f9f93
4
+ data.tar.gz: 658c839e4db49e21783adf36b638a8f58b1d9cf7
5
+ SHA512:
6
+ metadata.gz: 6688811554e1f5ca628340031170930dde4d72016863ec30e9fabc8a71830ac4ecd5d9ef5ebff926f02231d90520f21f202e2ff240133535f8cc81889c5e29ba
7
+ data.tar.gz: 769974b6daed94745e1b341452dd739595ccfef00e37eed944fa08acc69cfb9f9c0f8e31872196bf73417e96a7701c736993d3d680fcdc2f9854a9bb83328cc2
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jiri Kolarik
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # CarrierWave::FFmpeg
2
+
3
+ Simple Streamio FFmpeg wrapper for CarrierWave uploader
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'carrierwave-ffmpeg'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install carrierwave-ffmpeg
18
+
19
+ ## Usage
20
+
21
+ Include wrapper into your CarrierWave uploader class
22
+
23
+ ```ruby
24
+ class VideoUploader < CarrierWave::Uploader::Base
25
+ include CarrierWave::FFmpeg
26
+ end
27
+ ```
28
+
29
+ [Example](https://gist.github.com/JiriKolarik/7525989 "CarrierWave FFmpeg Uploader") of CarrierWave FFmpeg Uploader processing on background (carrierwave_backgrounder), converting to mp4, webm and ogv with multiple resolutions (Original, 1080p, 720p)
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require 'carrierwave/ffmpeg'
@@ -0,0 +1,55 @@
1
+ require 'carrierwave'
2
+ require 'streamio-ffmpeg'
3
+
4
+ module CarrierWave
5
+ module FFmpeg
6
+ module ClassMethods
7
+ def encode format, opts = {}
8
+ process encode: [ format, opts ]
9
+ end
10
+
11
+ def movie path
12
+ ::FFMPEG::Movie.new path
13
+ end
14
+ end
15
+
16
+ def encode format, opts = {}
17
+ tmp_path = File.join File.dirname(current_path), "tmp_file.#{format}"
18
+ file = movie current_path
19
+ file.transcode tmp_path, options(format, file, opts), transcoder_options
20
+ File.rename tmp_path, current_path
21
+ end
22
+
23
+ def codec format
24
+ case format
25
+ when :mp4
26
+ { video_codec: 'libx264',
27
+ audio_codec: 'libfaac' }
28
+ when :webm
29
+ { video_codec: 'libvpx',
30
+ audio_codec: 'libvorbis' }
31
+ when :ogv
32
+ { video_codec: 'libtheora',
33
+ audio_codec: 'libvorbis' }
34
+ else
35
+ raise CarrierWave::ProcessingError.new("Unsupported video format. Error: #{e}")
36
+ end
37
+ end
38
+
39
+ def options format, file, opts = {}
40
+ opts[:resolution] = file.resolution unless opts[:resolution]
41
+ opts[:video_bitrate] = file.bitrate unless opts[:video_bitrate]
42
+ opts[:video_bitrate_tolerance] = (opts[:video_bitrate].to_i / 10).to_i
43
+ opts[:threads] = 2 unless opts[:threads]
44
+ opts.merge!(codec(format))
45
+ end
46
+
47
+ def transcoder_options
48
+ { preserve_aspect_ratio: :height }
49
+ end
50
+
51
+ def movie path
52
+ ::FFMPEG::Movie.new path
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ module CarrierWave
2
+ module FFmpeg
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carrierwave-ffmpeg
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jiri Kolarik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: carrierwave
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: streamio-ffmpeg
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: CarrierWave FFmpeg
70
+ email:
71
+ - jiri.kolarik@imin.cz
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/carrierwave/ffmpeg/version.rb
77
+ - lib/carrierwave/ffmpeg.rb
78
+ - lib/carrierwave-ffmpeg.rb
79
+ - LICENSE.txt
80
+ - README.md
81
+ homepage: https://github.com/werein/carrierwave-ffmpeg
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.0.3
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Simple Streamio FFmpeg wrapper for CarrierWave uploader
105
+ test_files: []
106
+ has_rdoc: