apple-tv-converter 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/Gemfile.lock +44 -0
- data/README.md +3 -2
- data/bin/SublerCLI +0 -0
- data/gems/streamio-ffmpeg/CHANGELOG +198 -0
- data/gems/streamio-ffmpeg/Gemfile +3 -0
- data/gems/streamio-ffmpeg/LICENSE +20 -0
- data/gems/streamio-ffmpeg/README.md +180 -0
- data/gems/streamio-ffmpeg/Rakefile +22 -0
- data/gems/streamio-ffmpeg/lib/ffmpeg/encoding_options.rb +139 -0
- data/gems/streamio-ffmpeg/lib/ffmpeg/errors.rb +4 -0
- data/gems/streamio-ffmpeg/lib/ffmpeg/io_monkey.rb +42 -0
- data/gems/streamio-ffmpeg/lib/ffmpeg/movie.rb +206 -0
- data/gems/streamio-ffmpeg/lib/ffmpeg/stream.rb +15 -0
- data/gems/streamio-ffmpeg/lib/ffmpeg/transcoder.rb +120 -0
- data/gems/streamio-ffmpeg/lib/ffmpeg/version.rb +3 -0
- data/gems/streamio-ffmpeg/lib/streamio-ffmpeg.rb +49 -0
- data/gems/streamio-ffmpeg/spec/ffmpeg/encoding_options_spec.rb +135 -0
- data/gems/streamio-ffmpeg/spec/ffmpeg/movie_spec.rb +325 -0
- data/gems/streamio-ffmpeg/spec/ffmpeg/transcoder_spec.rb +210 -0
- data/gems/streamio-ffmpeg/spec/fixtures/bin/ffmpeg-audio-only +62 -0
- data/gems/streamio-ffmpeg/spec/fixtures/bin/ffmpeg-hanging +44 -0
- data/gems/streamio-ffmpeg/spec/fixtures/movies/awesome movie.mov +0 -0
- data/gems/streamio-ffmpeg/spec/fixtures/movies/awesome'movie.mov +0 -0
- data/gems/streamio-ffmpeg/spec/fixtures/movies/awesome_widescreen.mov +0 -0
- data/gems/streamio-ffmpeg/spec/fixtures/movies/broken.mp4 +0 -0
- data/gems/streamio-ffmpeg/spec/fixtures/movies/empty.flv +0 -0
- data/gems/streamio-ffmpeg/spec/fixtures/movies/sideways movie.mov +0 -0
- data/gems/streamio-ffmpeg/spec/fixtures/movies/weird_aspect.small.mpg +0 -0
- data/gems/streamio-ffmpeg/spec/fixtures/outputs/file_with_iso-8859-1.txt +35 -0
- data/gems/streamio-ffmpeg/spec/fixtures/outputs/file_with_no_audio.txt +18 -0
- data/gems/streamio-ffmpeg/spec/fixtures/outputs/file_with_non_supported_audio.txt +29 -0
- data/gems/streamio-ffmpeg/spec/fixtures/outputs/file_with_surround_sound.txt +19 -0
- data/gems/streamio-ffmpeg/spec/fixtures/outputs/file_with_weird_dar.txt +24 -0
- data/gems/streamio-ffmpeg/spec/fixtures/sounds/napoleon.mp3 +0 -0
- data/gems/streamio-ffmpeg/spec/spec_helper.rb +21 -0
- data/gems/streamio-ffmpeg/spec/streamio-ffmpeg_spec.rb +40 -0
- data/gems/streamio-ffmpeg/streamio-ffmpeg.gemspec +19 -0
- data/lib/apple_tv_converter.rb +10 -4
- data/lib/apple_tv_converter/apple_tv_converter.sublime-project +0 -6
- data/lib/apple_tv_converter/apple_tv_converter.sublime-workspace +501 -378
- data/lib/apple_tv_converter/command_line.rb +46 -22
- data/lib/apple_tv_converter/media.rb +49 -16
- data/lib/apple_tv_converter/media_converter.rb +19 -18
- data/lib/apple_tv_converter/media_converter_adapter.rb +58 -14
- data/lib/apple_tv_converter/media_converter_mac_adapter.rb +46 -35
- data/lib/apple_tv_converter/version.rb +1 -1
- metadata +49 -12
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
apple-tv-converter (0.3.0)
|
5
|
+
imdb (~> 0.6.8)
|
6
|
+
language_list (~> 0.0.3)
|
7
|
+
streamio-ffmpeg (~> 0.9.0)
|
8
|
+
|
9
|
+
PATH
|
10
|
+
remote: ./gems/streamio-ffmpeg
|
11
|
+
specs:
|
12
|
+
streamio-ffmpeg (0.9.0)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: http://rubygems.org/
|
16
|
+
specs:
|
17
|
+
awesome_print (1.1.0)
|
18
|
+
diff-lcs (1.1.3)
|
19
|
+
hpricot (0.8.6)
|
20
|
+
imdb (0.6.8)
|
21
|
+
hpricot (~> 0.8.4)
|
22
|
+
language_list (0.0.3)
|
23
|
+
rake (0.9.6)
|
24
|
+
rspec (2.12.0)
|
25
|
+
rspec-core (~> 2.12.0)
|
26
|
+
rspec-expectations (~> 2.12.0)
|
27
|
+
rspec-mocks (~> 2.12.0)
|
28
|
+
rspec-core (2.12.2)
|
29
|
+
rspec-expectations (2.12.1)
|
30
|
+
diff-lcs (~> 1.1.3)
|
31
|
+
rspec-mocks (2.12.2)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
x86-mingw32
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
apple-tv-converter!
|
39
|
+
awesome_print
|
40
|
+
imdb
|
41
|
+
language_list
|
42
|
+
rake (~> 0.9.2)
|
43
|
+
rspec (~> 2.7)
|
44
|
+
streamio-ffmpeg!
|
data/README.md
CHANGED
@@ -4,9 +4,8 @@ Command line utility to convert media to a format playable on the AppleTV. Suppo
|
|
4
4
|
|
5
5
|
## On Mac OSX
|
6
6
|
|
7
|
-
- Uses [ffmpeg](http://ffmpeg.org) to encode video and audio
|
7
|
+
- Uses [ffmpeg](http://ffmpeg.org) to encode video and audio, as well as extracting embedded subtitles
|
8
8
|
- Uses [Subler](http://code.google.com/p/subler/)'s command line interface to add the subtitles and set the iTunes metadata tags
|
9
|
-
- Uses [MKVToolNix](http://www.bunkus.org/videotools/mkvtoolnix/) to extract the embedded subtitles from MKV files
|
10
9
|
|
11
10
|
# Command line usage
|
12
11
|
|
@@ -20,6 +19,8 @@ Usage: apple-tv-converter [options] [file]
|
|
20
19
|
-l, --languages eng,por,... Only keep audio and subtitles in the specified languages
|
21
20
|
-d, --dir [DIRECTORY] Process all files in DIRECTORY recursively
|
22
21
|
--itunes Add processed file to iTunes library, if it isn't there yet
|
22
|
+
--imdb [ID] Gather data from IMDB (optionally specifying movie id. If an id isn't specified
|
23
|
+
the program looks for a file on the same directory, named <id>.imdb)
|
23
24
|
|
24
25
|
Common options:
|
25
26
|
-h, --help Show this message
|
data/bin/SublerCLI
ADDED
Binary file
|
@@ -0,0 +1,198 @@
|
|
1
|
+
== HEAD
|
2
|
+
|
3
|
+
Improvements:
|
4
|
+
* Simpler implementation for timeouts.
|
5
|
+
Should be far less cpu and memory dependent (don't spawn a thread for every line of output)
|
6
|
+
Timeout spec now passes in Rubinius (using 1.9 mode)
|
7
|
+
* Give helpful error message for windows users lacking the win32-process gem (thanks casoetan)
|
8
|
+
* Add Movie#container (thanks vitalis)
|
9
|
+
|
10
|
+
Changes:
|
11
|
+
* Default timeout lowered to 30 seconds
|
12
|
+
|
13
|
+
Bugs:
|
14
|
+
* Avoid crash if asking for frame_rate of a video without video stream (thanks squidarth)
|
15
|
+
* Fix crash when doing audio transcoding on ffmpeg >= 1.0.1 (thanks vitalis)
|
16
|
+
|
17
|
+
Deprecations:
|
18
|
+
* Removed support for Ruby 1.8
|
19
|
+
* Removed support for ffmpeg 0.7
|
20
|
+
|
21
|
+
Refactorings:
|
22
|
+
* Quite a few, see commit history for details.
|
23
|
+
|
24
|
+
== 0.9.0 2012-07-24
|
25
|
+
|
26
|
+
New:
|
27
|
+
* Bumped target ffmpeg version to 0.11.1
|
28
|
+
* Add hung process detection with configurable timeout (thanks stakach)
|
29
|
+
* Raise FFMPEG::Error instead of generic RuntimeError on failed transcodings
|
30
|
+
* Movie#screenshot for more intuitive screenshotting (README has details)
|
31
|
+
* Movie#creation_time and Movie#rotation attributes when metadata is available (thanks Innonate)
|
32
|
+
|
33
|
+
Bugs:
|
34
|
+
* Fixed too many open files bug (thanks to akicho8)
|
35
|
+
* Fixed missing path escaping (thanks to mikesager)
|
36
|
+
* Fixed README typo (thanks to Linutux)
|
37
|
+
* Files outputing "could not find codec parameters" are now recognized as invalid
|
38
|
+
|
39
|
+
Deprecations:
|
40
|
+
* Removed Movie#uncertain_duration?
|
41
|
+
* Removed all the deprecated crop options (use :custom => '-vf crop=x:x:x:x' if you need it)
|
42
|
+
|
43
|
+
Refactorings:
|
44
|
+
* Removed the deprecated duration validation code
|
45
|
+
* Polish on the transcoder class
|
46
|
+
* Polish on the spec suite
|
47
|
+
|
48
|
+
== 0.8.5 2011-03-05
|
49
|
+
|
50
|
+
* If a clip has a DAR that doesn't make sense fall back to calculating aspect ratio from dimensions
|
51
|
+
* Allow filenames with single quote characters (thanks to youpy)
|
52
|
+
|
53
|
+
== 0.8.4 2011-11-30
|
54
|
+
|
55
|
+
* Duration now one decimal more accurate (thanks to Russel Brooks)
|
56
|
+
* Added encoding option seek_time (thanks to Misty De Meo)
|
57
|
+
|
58
|
+
== 0.8.3 2011-09-01
|
59
|
+
|
60
|
+
* Parameters now come in the order of codecs, presets, others so that we can override the presets
|
61
|
+
* Added encoding option keyframe_interval to set number of frames between i-frames (aka GOP size)
|
62
|
+
* Streamio (sponsor of this project) have launched new awesome pricing @ http://streamio.com
|
63
|
+
|
64
|
+
== 0.8.2 2011-08-19
|
65
|
+
|
66
|
+
* Path to ffmpeg binary can now be specified (thanks jonathandean)
|
67
|
+
* If ffmpeg output contains "is not supported" the Movie will be considered invalid
|
68
|
+
|
69
|
+
== 0.8.1 2011-07-28
|
70
|
+
|
71
|
+
* Fix progress yielding with ffmpeg 0.8
|
72
|
+
* Updated specs to pass with ffmpeg 0.8
|
73
|
+
|
74
|
+
== 0.8.0 2011-05-26
|
75
|
+
|
76
|
+
* Duration is now ALWAYS considered uncertain (we've noticed that ffmpeg is not always correct)
|
77
|
+
* This means that the duration check will normally never run (unless you manually hack @uncertain_duration to false)
|
78
|
+
* Movie#audio_channels now returns nil if there is no audio stream (instead of crashing)
|
79
|
+
* Development: Use Bundler
|
80
|
+
* Development: Update RSpec to 2.6
|
81
|
+
|
82
|
+
== 0.7.8 2011-04-04
|
83
|
+
|
84
|
+
* Fixed number of audio channels on files with 5.1 audio
|
85
|
+
|
86
|
+
== 0.7.7 2011-02-01
|
87
|
+
|
88
|
+
* Movies with starttime are now considered as having uncertain duration as its behavior is not consistent across formats
|
89
|
+
* Upgrade development environment to RSpec 2.4
|
90
|
+
|
91
|
+
== 0.7.6 2011-01-14
|
92
|
+
|
93
|
+
* Another ruby 1.9 encoding fix
|
94
|
+
|
95
|
+
== 0.7.5 2011-01-14
|
96
|
+
|
97
|
+
* Fixed some ruby 1.9 issues
|
98
|
+
* Added Movie#video_bitrate and Movie#audio_bitrate (thanks to mbj)
|
99
|
+
|
100
|
+
== 0.7.4 2010-12-07
|
101
|
+
|
102
|
+
* Fixed broken duration on movies with start times over 0 by reducing duration with start-time
|
103
|
+
|
104
|
+
== 0.7.3 2010-08-26
|
105
|
+
|
106
|
+
* Replaced Jewler with simple dynamic gemspec file
|
107
|
+
* Spec files now not in published gem to make it a lot smaller in size
|
108
|
+
* Full output from ffmpeg command in error raised during transcoding
|
109
|
+
|
110
|
+
== 0.7.2 2010-08-11
|
111
|
+
|
112
|
+
* Added encoding option duration
|
113
|
+
* Avoid crashing when ffmpeg can't find resolution of a movie
|
114
|
+
|
115
|
+
== 0.7.1 2010-07-08
|
116
|
+
|
117
|
+
* Make sure preset parameters are always put last to avoid them ending up before any codec assignments
|
118
|
+
* Testing against a fresh ffmpeg build (r24069)
|
119
|
+
|
120
|
+
== 0.7.0 2010-07-07
|
121
|
+
|
122
|
+
* Support for ffpresets through video_preset, audio_preset and file_preset encoding options
|
123
|
+
* Added encoding option video_bitrate_tolerance
|
124
|
+
|
125
|
+
== 0.6.8.1 2010-07-06
|
126
|
+
|
127
|
+
* Bugfix - aspect ratio was not calculated properly on movies with no DAR
|
128
|
+
|
129
|
+
== 0.6.8 2010-07-06
|
130
|
+
|
131
|
+
* Don't use encoding options with nil values
|
132
|
+
* Added encoding options video_max_bitrate, video_min_bitrate and buffer_size for constant bitrate encoding
|
133
|
+
|
134
|
+
== 0.6.7 2010-06-10
|
135
|
+
|
136
|
+
* Bugfix - aspect ratio preserver could suggest non even resolutions in certain circumstances
|
137
|
+
|
138
|
+
== 0.6.6 2010-06-10
|
139
|
+
|
140
|
+
* Transcodings to .jpg and .png will now work as they will skip duration validation
|
141
|
+
|
142
|
+
== 0.6.5 2010-05-19
|
143
|
+
|
144
|
+
* Movie#size method to get file size.
|
145
|
+
|
146
|
+
== 0.6.4 2010-05-12
|
147
|
+
|
148
|
+
* Ruby 1.9 compatibility fix for EncodingOptions (thanks michalf!)
|
149
|
+
|
150
|
+
== 0.6.3 2010-05-05
|
151
|
+
|
152
|
+
* Use DAR to calculate aspect ratio if available
|
153
|
+
|
154
|
+
== 0.6.2 2010-05-05
|
155
|
+
|
156
|
+
* Added Movie#uncertain_duration? which is true if ffmpeg is guessing duration from bitrate
|
157
|
+
* Skipping the transcoders duration validation if original file has uncertain duration
|
158
|
+
* Made sure aspect ratio preservation always rounds new size to an even number to avoid "not divisible by 2" errors
|
159
|
+
* Changed Movie#valid? logic to accept any movie with either a readable audio or video stream
|
160
|
+
|
161
|
+
== 0.6.0 2010-05-04
|
162
|
+
|
163
|
+
* Cropping options now handled by EncodingOptions (croptop, cropbottom, cropleft and cropright)
|
164
|
+
* Aspect ratio parameter calculated and added by default
|
165
|
+
* Added transcoder options to preserve original aspect ratio on width or height
|
166
|
+
|
167
|
+
== 0.5.0 2010-04-28
|
168
|
+
|
169
|
+
* Added logging capabilities
|
170
|
+
|
171
|
+
== 0.4.3 2010-04-06
|
172
|
+
|
173
|
+
* Correctly identify invalid movies on latest ffmpeg build (r22811)
|
174
|
+
|
175
|
+
== 0.4.2 2010-04-06
|
176
|
+
|
177
|
+
* Escape the path to handle spaces in filenames and avoid CLI injection attacks (thanks J. Weir!)
|
178
|
+
|
179
|
+
== 0.4.1 2010-02-10
|
180
|
+
|
181
|
+
* Forgot to change the transcoding shortcut from Movie
|
182
|
+
|
183
|
+
== 0.4.0 2010-02-10
|
184
|
+
|
185
|
+
* Transcoding API changed to make use of more humanly readable options (see README for examples)
|
186
|
+
* Fixed frame rate parsing for integer frame rates
|
187
|
+
|
188
|
+
== 0.3.0 2010-02-07
|
189
|
+
|
190
|
+
* Simple transcoding
|
191
|
+
|
192
|
+
== 0.2.0 2010-02-06
|
193
|
+
|
194
|
+
* Some more metadata parsing
|
195
|
+
|
196
|
+
== 0.1.0 2010-02-05
|
197
|
+
|
198
|
+
* Some basic parsing of metadata added
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Streamio AB
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,180 @@
|
|
1
|
+
Streamio FFMPEG
|
2
|
+
===============
|
3
|
+
|
4
|
+
Simple yet powerful wrapper around the ffmpeg command for reading metadata and transcoding movies.
|
5
|
+
|
6
|
+
All work on this project is sponsored by the online video platform [Streamio](http://streamio.com).
|
7
|
+
|
8
|
+
[![Streamio](http://d253c4ja9jigvu.cloudfront.net/assets/small-logo.png)](http://streamio.com)
|
9
|
+
|
10
|
+
Installation
|
11
|
+
------------
|
12
|
+
|
13
|
+
(sudo) gem install streamio-ffmpeg
|
14
|
+
|
15
|
+
Compatibility
|
16
|
+
-------------
|
17
|
+
|
18
|
+
### Ruby
|
19
|
+
|
20
|
+
Only guaranteed to work with MRI Ruby 1.9.3 or later.
|
21
|
+
Should work with rubinius head in 1.9 mode.
|
22
|
+
Will not work in jruby until they fix: http://goo.gl/Z4UcX (should work in the upcoming 1.7.2)
|
23
|
+
|
24
|
+
### ffmpeg
|
25
|
+
|
26
|
+
The current gem is tested against ffmpeg 0.11.1. So no guarantees with earlier (or much later) versions. Output and input standards have inconveniently changed rather a lot between versions of ffmpeg. My goal is to keep this library in sync with new versions of ffmpeg as they come along.
|
27
|
+
|
28
|
+
Usage
|
29
|
+
-----
|
30
|
+
|
31
|
+
### Require the gem
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
require 'rubygems'
|
35
|
+
require 'streamio-ffmpeg'
|
36
|
+
```
|
37
|
+
|
38
|
+
### Reading Metadata
|
39
|
+
|
40
|
+
``` ruby
|
41
|
+
movie = FFMPEG::Movie.new("path/to/movie.mov")
|
42
|
+
|
43
|
+
movie.duration # 7.5 (duration of the movie in seconds)
|
44
|
+
movie.bitrate # 481 (bitrate in kb/s)
|
45
|
+
movie.size # 455546 (filesize in bytes)
|
46
|
+
|
47
|
+
movie.video_stream # "h264, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 371 kb/s, 16.75 fps, 15 tbr, 600 tbn, 1200 tbc" (raw video stream info)
|
48
|
+
movie.video_codec # "h264"
|
49
|
+
movie.colorspace # "yuv420p"
|
50
|
+
movie.resolution # "640x480"
|
51
|
+
movie.width # 640 (width of the movie in pixels)
|
52
|
+
movie.height # 480 (height of the movie in pixels)
|
53
|
+
movie.frame_rate # 16.72 (frames per second)
|
54
|
+
|
55
|
+
movie.audio_stream # "aac, 44100 Hz, stereo, s16, 75 kb/s" (raw audio stream info)
|
56
|
+
movie.audio_codec # "aac"
|
57
|
+
movie.audio_sample_rate # 44100
|
58
|
+
movie.audio_channels # 2
|
59
|
+
|
60
|
+
movie.valid? # true (would be false if ffmpeg fails to read the movie)
|
61
|
+
```
|
62
|
+
|
63
|
+
### Transcoding
|
64
|
+
|
65
|
+
First argument is the output file path.
|
66
|
+
|
67
|
+
``` ruby
|
68
|
+
movie.transcode("tmp/movie.mp4") # Default ffmpeg settings for mp4 format
|
69
|
+
```
|
70
|
+
|
71
|
+
Keep track of progress with an optional block.
|
72
|
+
|
73
|
+
``` ruby
|
74
|
+
movie.transcode("movie.mp4") { |progress| puts progress } # 0.2 ... 0.5 ... 1.0
|
75
|
+
```
|
76
|
+
|
77
|
+
Give custom command line options with a string.
|
78
|
+
|
79
|
+
``` ruby
|
80
|
+
movie.transcode("movie.mp4", "-ac aac -vc libx264 -ac 2 ...")
|
81
|
+
```
|
82
|
+
|
83
|
+
Use the EncodingOptions parser for humanly readable transcoding options. Below you'll find most of the supported options. Note that the :custom key will be used as is without modification so use it for any tricky business you might need.
|
84
|
+
|
85
|
+
``` ruby
|
86
|
+
options = {video_codec: "libx264", frame_rate: 10, resolution: "320x240", video_bitrate: 300, video_bitrate_tolerance: 100,
|
87
|
+
aspect: 1.333333, keyframe_interval: 90,
|
88
|
+
audio_codec: "libfaac", audio_bitrate: 32, audio_sample_rate: 22050, audio_channels: 1,
|
89
|
+
threads: 2,
|
90
|
+
custom: "-vf crop=60:60:10:10"}
|
91
|
+
movie.transcode("movie.mp4", options)
|
92
|
+
```
|
93
|
+
|
94
|
+
The transcode function returns a Movie object for the encoded file.
|
95
|
+
|
96
|
+
``` ruby
|
97
|
+
transcoded_movie = movie.transcode("tmp/movie.flv")
|
98
|
+
|
99
|
+
transcoded_movie.video_codec # "flv"
|
100
|
+
transcoded_movie.audio_codec # "mp3"
|
101
|
+
```
|
102
|
+
|
103
|
+
Aspect ratio is added to encoding options automatically if none is specified.
|
104
|
+
|
105
|
+
``` ruby
|
106
|
+
options = { resolution: "320x180" } # Will add -aspect 1.77777777777778 to ffmpeg
|
107
|
+
```
|
108
|
+
|
109
|
+
Preserve aspect ratio on width or height by using the preserve_aspect_ratio transcoder option.
|
110
|
+
|
111
|
+
``` ruby
|
112
|
+
widescreen_movie = FFMPEG::Movie.new("path/to/widescreen_movie.mov")
|
113
|
+
|
114
|
+
options = { resolution: "320x240" }
|
115
|
+
|
116
|
+
transcoder_options = { preserve_aspect_ratio: :width }
|
117
|
+
widescreen_movie.transcode("movie.mp4", options, transcoder_options) # Output resolution will be 320x180
|
118
|
+
|
119
|
+
transcoder_options = { preserve_aspect_ratio: :height }
|
120
|
+
widescreen_movie.transcode("movie.mp4", options, transcoder_options) # Output resolution will be 426x240
|
121
|
+
```
|
122
|
+
|
123
|
+
For constant bitrate encoding use video_min_bitrate and video_max_bitrate with buffer_size.
|
124
|
+
|
125
|
+
``` ruby
|
126
|
+
options = {video_min_bitrate: 600, video_max_bitrate: 600, buffer_size: 2000}
|
127
|
+
movie.transcode("movie.flv", options)
|
128
|
+
```
|
129
|
+
|
130
|
+
### Taking Screenshots
|
131
|
+
|
132
|
+
You can use the screenshot method to make taking screenshots a bit simpler.
|
133
|
+
|
134
|
+
``` ruby
|
135
|
+
movie.screenshot("screenshot.jpg")
|
136
|
+
```
|
137
|
+
|
138
|
+
The screenshot method has the very same API as transcode so the same options will work.
|
139
|
+
|
140
|
+
``` ruby
|
141
|
+
movie.screenshot("screenshot.bmp", seek_time: 5, resolution: '320x240')
|
142
|
+
```
|
143
|
+
|
144
|
+
You can preserve aspect ratio the same way as when using transcode.
|
145
|
+
|
146
|
+
``` ruby
|
147
|
+
movie.screenshot("screenshot.png", { seek_time: 2, resolution: '200x120' }, preserve_aspect_ratio: :width)
|
148
|
+
```
|
149
|
+
|
150
|
+
Specify the path to ffmpeg
|
151
|
+
--------------------------
|
152
|
+
|
153
|
+
By default, streamio assumes that the ffmpeg binary is available in the execution path and named ffmpeg and so will run commands that look something like "ffmpeg -i /path/to/input.file ...". Use the FFMPEG.ffmpeg_binary setter to specify the full path to the binary if necessary:
|
154
|
+
|
155
|
+
``` ruby
|
156
|
+
FFMPEG.ffmpeg_binary = '/usr/local/bin/ffmpeg'
|
157
|
+
```
|
158
|
+
|
159
|
+
This will cause the same command to run as "/usr/local/bin/ffmpeg -i /path/to/input.file ..." instead.
|
160
|
+
|
161
|
+
|
162
|
+
Automatically kill hung processes
|
163
|
+
---------------------------------
|
164
|
+
|
165
|
+
By default, streamio will wait for 30 seconds between IO feedback from the FFMPEG process. After which an error is logged and the process killed.
|
166
|
+
It is possible to modify this behaviour by setting a new default:
|
167
|
+
|
168
|
+
``` ruby
|
169
|
+
# Change the timeout
|
170
|
+
Transcoder.timeout = 10
|
171
|
+
|
172
|
+
# Disable the timeout altogether
|
173
|
+
Transcoder.timeout = false
|
174
|
+
```
|
175
|
+
|
176
|
+
|
177
|
+
Copyright
|
178
|
+
---------
|
179
|
+
|
180
|
+
Copyright (c) 2011 Streamio AB. See LICENSE for details.
|