rtranscoder 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,7 @@
1
+ == 0.0.9 / 2008-01-17
2
+
3
+ * Initial release.
4
+ * Supports FFmpeg
5
+ * Supports MPlayer
6
+ * Supports MEncoder
7
+
data/Manifest.txt ADDED
@@ -0,0 +1,21 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ examples/encode_flv.rb
6
+ examples/thumbnail.rb
7
+ lib/rtranscoder.rb
8
+ lib/rtranscoder/version.rb
9
+ lib/rtranscoder/extensions.rb
10
+ lib/rtranscoder/extensions/float.rb
11
+ lib/rtranscoder/ffmpeg.rb
12
+ lib/rtranscoder/ffmpeg/ffmpeg.rb
13
+ lib/rtranscoder/ffmpeg/ffmpeg_task.rb
14
+ lib/rtranscoder/ffmpeg/extensions.rb
15
+ lib/rtranscoder/ffmpeg/extensions/integer.rb
16
+ lib/rtranscoder/mplayer/mplayer_common_task.rb
17
+ lib/rtranscoder/mplayer/mplayer.rb
18
+ lib/rtranscoder/mplayer/mplayer_task.rb
19
+ lib/rtranscoder/mplayer/mencoder.rb
20
+ lib/rtranscoder/mplayer/mencoder_task.rb
21
+ test/test_rtranscoder.rb
data/README.txt ADDED
@@ -0,0 +1,52 @@
1
+ RTranscoder
2
+ by Hal Brodigan
3
+ http://rubyforge.org/projects/rtranscoder/
4
+
5
+ == DESCRIPTION:
6
+
7
+ A Rubyful interface to various transcoding utilities using the RProgram
8
+ library.
9
+
10
+ No more must one have to provide a shell command in order to run
11
+ ffmpeg or mencoder for one's transcoding needs. RTranscoder and RProgram
12
+ have mapped all the command-line options of various transcoding utilities
13
+ to Ruby classes and methods for your convenience.
14
+
15
+ == FEATURES/PROBLEMS:
16
+
17
+ * Supports FFmpeg.
18
+ * Supports MPlayer.
19
+ * Supports MEncoder.
20
+
21
+ == REQUIREMENTS:
22
+
23
+ * RProgram
24
+
25
+ == INSTALL:
26
+
27
+ $ sudo gem install rtranscoder
28
+
29
+ == LICENSE:
30
+
31
+ The MIT License
32
+
33
+ Copyright (c) 2008 Hal Brodigan
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining
36
+ a copy of this software and associated documentation files (the
37
+ 'Software'), to deal in the Software without restriction, including
38
+ without limitation the rights to use, copy, modify, merge, publish,
39
+ distribute, sublicense, and/or sell copies of the Software, and to
40
+ permit persons to whom the Software is furnished to do so, subject to
41
+ the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be
44
+ included in all copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
47
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
49
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
50
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
51
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
52
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/rtranscoder/version.rb'
6
+
7
+ Hoe.new('rtranscoder', RTranscoder::VERSION) do |p|
8
+ p.rubyforge_name = 'rtranscoder'
9
+ p.author = 'Hal Brodigan'
10
+ p.email = 'postmodern.mod3@gmail.com'
11
+ p.summary = 'A Rubyful interface to various transcoding utilities using the RProgram library.'
12
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
+ p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
+ p.extra_deps = [['rprogram', '>=0.1.0']]
16
+ end
17
+
18
+ # vim: syntax=Ruby
@@ -0,0 +1,17 @@
1
+ require 'rtranscoder/ffmpeg'
2
+
3
+ include RTranscoder
4
+
5
+ #
6
+ # Encodes a video to FLV.
7
+ # Equivalent to:
8
+ # $ ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv
9
+ #
10
+ FFmpeg.encode do |ffmpeg|
11
+ ffmpeg.input = 'video.avi'
12
+ ffmpeg.audio_sampling_rate = 22050 # Hz
13
+ ffmpeg.audio_bitrate = 32 # kbit/s
14
+ ffmpeg.video_frame_dimension = '320x240'
15
+ ffmpeg.output_format = :flv
16
+ ffmpeg.output = 'video.flv'
17
+ end
@@ -0,0 +1,29 @@
1
+ require 'rtranscoder/ffmpeg'
2
+
3
+ include RTranscoder
4
+
5
+ #
6
+ # Extracts a frame at 00:00:03.
7
+ # Equivlanent to:
8
+ # $ ffmpeg -i video.flv -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 320x240 \
9
+ # video_thumbnail.jpg
10
+ #
11
+ FFmpeg.encode do |ffmpeg|
12
+ ffmpeg.input = 'video.flv'
13
+ ffmpeg.disable_audio = true
14
+ ffmpeg.record_start_time = '00:00:03'
15
+ ffmpeg.record_for = '00:00:01'
16
+ ffmpeg.record_fps = 1
17
+ ffmpeg.overwrite_file = true
18
+ ffmpeg.output_dimension = '320x240'
19
+ ffmpeg.output = 'video_thumbnail%d.jpg'
20
+ end
21
+
22
+ #
23
+ # Or even simplier...
24
+ #
25
+ RTranscoder.thumbnail(:video => 'video.flv',
26
+ :start => '00:00:03',
27
+ :length => '00:00:01',
28
+ :dimension => '320x240',
29
+ :image => 'thumb%d.jpg')
@@ -0,0 +1,3 @@
1
+ require 'rtranscoder/version'
2
+ require 'rtranscoder/ffmpeg'
3
+ require 'rtranscoder/mplayer'
@@ -0,0 +1 @@
1
+ require 'rtranscoder/extensions/float'
@@ -0,0 +1,30 @@
1
+ class Float
2
+
3
+ #
4
+ # Returns the +Float+ in Hz as an +Integer+.
5
+ #
6
+ # 25.05.Hz # => 2505
7
+ #
8
+ def Hz
9
+ self.to_i
10
+ end
11
+
12
+ #
13
+ # Returns the +Float+ in kHz as an +Integer+.
14
+ #
15
+ # 1.337.kHz # => 1337
16
+ #
17
+ def kHz
18
+ (self * 1000).Hz
19
+ end
20
+
21
+ #
22
+ # Returns the +Float+ in kHz as an +Integer+.
23
+ #
24
+ # 2.6.mHz # => 2600000
25
+ #
26
+ def mHz
27
+ (self * 1000_000).Hz
28
+ end
29
+
30
+ end
@@ -0,0 +1,2 @@
1
+ require 'rtranscoder/ffmpeg/ffmpeg'
2
+ require 'rtranscoder/ffmpeg/rtranscoder'
@@ -0,0 +1 @@
1
+ require 'rtranscoder/ffmpeg/extensions/integer'
@@ -0,0 +1,12 @@
1
+ class Integer
2
+
3
+ #
4
+ # Returns an FFmpeg dimension +String+ of +self+ by the specified _height_.
5
+ #
6
+ # 640.by(480) # => "640x480"
7
+ #
8
+ def by(height)
9
+ "#{self}x#{height}"
10
+ end
11
+
12
+ end
@@ -0,0 +1,67 @@
1
+ require 'rtranscoder/ffmpeg/ffmpeg_task'
2
+ require 'rtranscoder/ffmpeg/extensions'
3
+ require 'rtranscoder/extensions'
4
+
5
+ require 'rprogram/program'
6
+
7
+ module RTranscoder
8
+ class FFmpeg < RProgram::Program
9
+
10
+ name_program 'ffmpeg'
11
+
12
+ #
13
+ # Creates a new FFmpeg object with the specified _path_ of the +ffmpeg+
14
+ # program.
15
+ #
16
+ def initialize(path)
17
+ super(path)
18
+ end
19
+
20
+ #
21
+ # See FFmpeg#encode.
22
+ #
23
+ def self.encode(options={},&block)
24
+ self.create.encode(options,&block)
25
+ end
26
+
27
+ #
28
+ # See FFmpeg#thumbnail.
29
+ #
30
+ def self.thumbnail(options={})
31
+ self.create.thumbnail(options)
32
+ end
33
+
34
+ #
35
+ # Runs the +ffmpeg+ program with the given _options_ and the given
36
+ # _block_ using FFmpegTask.
37
+ #
38
+ def encode(options={},&block)
39
+ run_with_task(FFmpegTask.new(options,&block))
40
+ end
41
+
42
+ #
43
+ # Extracts a thumbnail using the given _options_.
44
+ #
45
+ # _options_ may contain the following keys:
46
+ # <tt>:video</tt>:: The input video file.
47
+ # <tt>:start</tt>:: The start timestamp of the thumbnail.
48
+ # <tt>:length</tt>:: The duration time of the thumbnail.
49
+ # <tt>:fps</tt>:: The FPS to use, defaults to 1.
50
+ # <tt>:dimension</tt>:: The dimension of the thumbnail.
51
+ # <tt>:image</tt>:: The output thumbnail image.
52
+ #
53
+ def thumbnail(options={})
54
+ encode do |ffmpeg|
55
+ ffmpeg.input = options[:video]
56
+ ffmpeg.disable_audio = true
57
+ ffmpeg.record_start_time = options[:start]
58
+ ffmpeg.record_for = options[:length]
59
+ ffmpeg.record_fps = (options[:fps] || 1)
60
+ ffmpeg.overwrite_file = true
61
+ ffmpeg.output_dimension = options[:dimension]
62
+ ffmpeg.output = options[:image]
63
+ end
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,221 @@
1
+ require 'rprogram/task'
2
+
3
+ module RTranscoder
4
+ class FFmpegTask < RProgram::Task
5
+
6
+ # Main options
7
+ short_option :flag => '-L', :name => :license
8
+ short_option :flag => '-h', :name => :help
9
+ long_option :flag => '-version'
10
+ short_option :flag => '-f', :name => :output_format
11
+ short_option :flag => '-i', :name => :input
12
+ short_option :flag => '-y', :name => :overwrite_output_files
13
+ short_option :flag => '-t', :name => :record_for
14
+ short_option :flag => '-fs', :name => :limit_file_size
15
+ short_option :flag => '-ss', :name => :record_start_time
16
+ long_option :flag => '-itsoffset', :name => :input_ts_offset
17
+ long_option :flag => '-title'
18
+ long_option :flag => '-timestamp'
19
+ long_option :flag => '-author'
20
+ long_option :flag => '-copyright'
21
+ long_option :flag => '-comment'
22
+ long_option :flag => '-album'
23
+ short_option :flag => '-v', :name => :verbose
24
+ long_option :flag => '-target'
25
+ long_option :flag => '-dframes', :name => :data_frames
26
+
27
+ # Video options
28
+ long_option :flag => '-vframes', :name => :video_frames
29
+ short_option :flag => '-r', :name => :fps
30
+ short_option :flag => '-s', :name => :video_frame_dimension
31
+ long_option :flag => '-aspect', :name => :aspect_ratio
32
+ long_option :flag => '-croptop', :name => :crop_top
33
+ long_option :flag => '-cropbottom', :name => :crop_bottom
34
+ long_option :flag => '-cropleft', :name => :crop_left
35
+ long_option :flag => '-cropright', :name => :crop_right
36
+ long_option :flag => '-padtop', :name => :pad_top
37
+ long_option :flag => '-padbottom', :name => :pad_bottom
38
+ long_option :flag => '-padleft', :name => :pad_left
39
+ long_option :flag => '-padright', :name => :pad_right
40
+ long_option :flag => '-padcolor', :name => :pad_color
41
+ long_option :flag => '-vn', :name => :disable_video
42
+ long_option :flag => '-vcodec', :name => :video_codec
43
+ long_option :flag => '-sameq', :name => :preserve_video_quality
44
+ long_option :flag => '-pass', :name => :pass
45
+ long_option :flag => '-passlogfile', :name => :pass_log_file
46
+ long_option :flag => '-newvideo', :name => :new_video_stream
47
+
48
+ # Advanced Video options
49
+ long_option :flag => '-pix_fmt', :name => :pixel_format
50
+ long_option :flag => '-intra', :name => :only_intra_frames
51
+ long_option :flag => '-vdt', :name => :discard_threshold
52
+ long_option :flag => '-qscale'
53
+ long_option :flag => '-qdiff'
54
+ long_option :flag => '-rc_eq', :name => :rate_control_equation
55
+ long_option :flag => '-rc_override', :name => :rate_control_override
56
+ long_option :flag => '-me', :name => :motion_estimation_method
57
+ long_option :flag => '-me_threshold', :name => :motion_estimation_threshold
58
+ long_option :flag => '-strict', :name => :strictness
59
+ long_option :flag => '-deinterlace', :name => :deinterlace
60
+ long_option :flag => '-psnr', :name => :calculate_psnr
61
+ long_option :flag => '-vstats', :name => :dump_video_coding_statistics
62
+ long_option :flag => '-vstats_file', :name => :log_video_coding_statistics
63
+ long_option :flag => '-vhook', :name => :video_processing_module
64
+ long_option :flag => '-intra_matrix'
65
+ long_option :flag => '-inter_matrix'
66
+ long_option :flag => '-top'
67
+ long_option :flag => '-dc', :name => :intra_dc_precision
68
+ long_option :flag => '-vtag', :name => :force_video_tag
69
+ long_option :flag => '-qphist', :name => :qp_histogram
70
+ long_option :flag => '-vbsf', :name => :bitstream_filter
71
+
72
+ # Audio options
73
+ long_option :flag => '-aframes', :name => :audio_frames
74
+ long_option :flag => '-aq', :name => :audio_quality
75
+ long_option :flag => '-ar', :name => :audio_sampling_rate
76
+ long_option :flag => '-ac', :name => :audio_channels
77
+ long_option :flag => '-an', :name => :disable_audio
78
+ long_option :flag => '-acodec', :name => :audio_codec
79
+ long_option :flag => '-vol', :name => :audio_volume
80
+ long_option :flag => '-newaudio', :name => :new_audio_stream
81
+ long_option :flag => '-alang', :name => :audio_language_code
82
+
83
+ # Advanced Audio options
84
+ long_option :flag => '-atag', :name => :force_audio_tag
85
+ long_option :flag => '-absf', :name => :audio_bitstream_filter
86
+
87
+ # Subtitle options
88
+ long_option :flag => '-scodec', :name => :subtitle_codec
89
+ long_option :flag => '-newsubtitle', :name => :new_subtitles_stream
90
+ long_option :flag => '-slang', :name => :subtitle_language_code
91
+
92
+ # Audio/Video options
93
+ long_option :flag => '-vc', :name => :video_graph_channel
94
+ long_option :flag => '-tvstd', :name => :television_standard
95
+ long_option :flag => '-isync', :name => :sync_read_on_input
96
+
97
+ # Advanced options
98
+ long_option :flag => '-map', :name => :input_stream_mapping
99
+ long_option :flag => '-map_meta_data', :name => :metadata_mapping
100
+ long_option :flag => '-benchmark'
101
+ long_option :flag => '-dump'
102
+ long_option :flag => '-hex'
103
+ long_option :flag => '-re', :name => :read_at_native_fps
104
+ long_option :flag => '-loop_input'
105
+ long_option :flag => '-loop_output'
106
+ long_option :flag => '-threads'
107
+ long_option :flag => '-vsync', :name => :video_sync
108
+ long_option :flag => '-async', :name => :audio_sync
109
+ long_option :flag => '-vglobal', :name => :video_global_header
110
+ long_option :flag => '-copyts', :name => :copy_timestams
111
+ long_option :flag => '-shortest'
112
+ long_option :flag => '-dts_delta_threshold'
113
+ long_option :flag => '-muxdelay', :name => :maximum_demux_delay
114
+ long_option :flag => '-muxpreload', :name => :initial_demux_delay
115
+
116
+ # AVCodecContext AVOptions
117
+ short_option :flag => '-b', :name => :video_bitrate
118
+ short_option :flag => '-ab', :name => :audio_bitrate
119
+ long_option :flag => '-flags'
120
+ short_option :flag => '-g', :name => :group_picture_size
121
+ long_option :flag => '-cutoff', :name => :audio_bandwidth_cutoff
122
+ long_option :flag => '-frame_size', :name => :audio_frame_size
123
+ long_option :flag => '-rc_strategy', :name => :video_ratecontrol_method
124
+ long_option :flag => '-hurry_up'
125
+ long_option :flag => '-ps', :name => :video_rtp_payload_size
126
+ long_option :flag => '-bug'
127
+ long_option :flag => '-mpeg_quant', :name => :mpeg_quantizers
128
+ long_option :flag => '-rc_eq', :name => :video_rate_control
129
+ long_option :flag => '-maxrate', :name => :max_video_bitrate
130
+ long_option :flag => '-minrate', :name => :max_video_bitrate
131
+ long_option :flag => '-bufsize', :name => :video_ratecontrol_buffer_size
132
+ long_option :flag => '-rc_buf_aggressivity', :name => :currently_useless
133
+ long_option :flag => '-rc_init_cplx', :name => :initial_pass_complexity
134
+ long_option :flag => '-dct', :name => :dct_algorithm
135
+ long_option :flag => '-lumi_mask', :name => :luminescence_mask
136
+ long_option :flag => '-tcplx_mask', :name => :temporal_complexity_masking
137
+ long_option :flag => '-scplx_mask', :name => :spatial_complexity_masking
138
+ long_option :flag => '-dark_mask', :name => :darkness_mask
139
+ long_option :flag => '-idct', :name => :idct_implementation
140
+ long_option :flag => '-ec', :name => :error_concealment
141
+ long_option :flag => '-pred', :name => :encoding_prediction_method
142
+ long_option :flag => '-aspect', :name => :encoding_sample_aspect_ratio
143
+ long_option :flag => '-debug'
144
+ long_option :flag => '-vismv', :name => :visualize_motion_vectors
145
+ long_option :flag => '-cmp', :name => :full_pel_motion_estimation_compare
146
+ long_option :flag => '-subcmp', :name => :sub_full_pel_motion_estimation_compare
147
+ long_option :flag => '-mbcomp', :name => :marcoblock_compare_function
148
+ long_option :flag => '-dia_size', :name => :diamond_type_and_size
149
+ long_option :flag => '-last_pred', :name => :motion_preditors_from_previous
150
+ long_option :flag => '-preme', :name => :pre_motion_estimation
151
+ long_option :flag => '-precmp', :name => :pre_motion_estimation_compare
152
+ long_option :flag => '-pre_dia_size', :name => :pre_pass_diamond_type_and_size
153
+ long_option :flag => '-subq', :name => :sub_pel_motion_estimation_quality
154
+ long_option :flag => '-me_range', :name => :limit_motion_vectors_range
155
+ long_option :flag => '-ibias', :name => :intra_quant_bias
156
+ long_option :flag => '-pbias', :name => :inter_quant_bias
157
+ long_option :flag => '-coder', :name => :video_coder
158
+ long_option :flag => '-context', :name => :video_encoding_context_model
159
+ long_option :flag => '-mbd', :name => :macroblock_decision_algorithm
160
+ long_option :flag => '-sc_threshold', :name => :encoding_scene_change_threshold
161
+ long_option :flag => '-lmin', :name => :min_lag_range_factor
162
+ long_option :flag => '-lmax', :name => :max_lag_range_factor
163
+ long_option :flag => '-nr', :name => :noise_reduction
164
+ long_option :flag => '-inter_threshold'
165
+ long_option :flag => '-flags2', :name => :extra_flags
166
+ long_option :flag => '-qns', :name => :quantizer_noise_shaping
167
+ long_option :flag => '-threads'
168
+ long_option :flag => '-mb_threshold', :name => :macroblock_threshold
169
+ long_option :flag => '-dc', :name => :intra_dc_precision
170
+ long_option :flag => '-nssew', :name => :nsse_weight
171
+ long_option :flag => '-skip_top', :name => :skip_top_macroblock_rows
172
+ long_option :flag => '-skip_bottom', :name => :skip_bottom_macroblock_rows
173
+ long_option :flag => '-profile', :name => :encoding_profile
174
+ long_option :flag => '-level', :name => :encoding_level
175
+ long_option :flag => '-lowres', :name => :lowres_decode
176
+ long_option :flag => '-skip_threshold', :name => :frame_skip_threshold
177
+ long_option :flag => '-skip_factor', :name => :frame_skip_factor
178
+ long_option :flag => '-skip_ext', :name => :frame_skip_exponent
179
+ long_option :flag => '-skipcmp', :name => :frame_skip_compare
180
+ long_option :flag => '-border_mask'
181
+ long_option :flag => '-mblmin', :name => :min_macroblock_lag_range_factor
182
+ long_option :flag => '-mblmax', :name => :max_macroblock_lag_range_factor
183
+ long_option :flag => '-mepc', :name => :motion_estimation_bitrate_penalty
184
+ long_option :flag => '-crf', :name => :constant_quality_mode
185
+ long_option :flag => '-cpp', :name => :constant_quantization_parameter_rate_control
186
+ long_option :flag => '-keyint_min', :name => :min_interval_between_idr_frames
187
+ long_option :flag => '-refs', :name => :ref_frames_for_motion_compensation
188
+ long_option :flag => '-chromaoffset', :name => :chroma_gp_offset_from_luma
189
+ long_option :flag => '-bframebias', :name => :influences_b_frame_usage
190
+ long_option :flag => '-trellis', :name => :rate_distortion_optimal_quantization
191
+ long_option :flag => '-directpred 1', :name => :direct_mv_prediction
192
+ long_option :flag => '-complexityblur', :name => :reduce_gp_fluctuations
193
+ long_option :flag => '-deblockalpha', :name => :alphac0_deblocking
194
+ long_option :flag => '-deblockbeta', :name => :beta_deblocking
195
+ long_option :flag => '-partitions', :name => :macroblock_subpartition_size
196
+ long_option :flag => '-sc_factor', :name => :scene_change_modifier
197
+ long_option :flag => '--mv0_threshold'
198
+ long_option :flag => '-b_sensitivity', :name => :b_frame_sensitivity
199
+ long_option :flag => '-compression_level'
200
+ long_option :flag => '-use_lpc', :name => :lpc_mode
201
+ long_option :flag => '-lpc_coeff_precision', :name => :lpc_coefficient_precision
202
+ long_option :flag => '-min_prediction_order'
203
+ long_option :flag => '-max_prediction_order'
204
+ long_option :flag => '-prediction_order_method'
205
+ long_option :flag => '-min_partition_order', :name => :min_audio_partition_order
206
+ long_option :flag => '-max_partition_order', :name => :max_audio_partition_order
207
+ long_option :flag => '-timecode_frame_start', :name => :gop_timecode_frame_start
208
+
209
+ # AVFormatContext options
210
+ long_option :flag => '-probesize', :name => :decoding_probe_size
211
+ long_option :flag => '-muxrate', :name => :encoding_mux_rate
212
+ long_option :flag => '-packetsize', :name => :encoding_packet_size
213
+ long_option :flag => '-fflags'
214
+ long_option :flag => '-encoding_track'
215
+ long_option :flag => '-encoding_year'
216
+ long_option :flag => '-analyzeduration', :name => :decoding_analyze_duration
217
+
218
+ non_option :name => :output
219
+
220
+ end
221
+ end
@@ -0,0 +1,35 @@
1
+ require 'rtranscoder/mencoder/mencoder_task'
2
+ require 'rtranscoder/extensions'
3
+
4
+ require 'rprogram/program'
5
+
6
+ module RTranscoder
7
+ class MEncoder < RProgram::Program
8
+
9
+ name_program :mencoder
10
+
11
+ #
12
+ # Creates a new MEncoder object with the specified _path_ of the
13
+ # +mencoder+ program.
14
+ #
15
+ def initialize(path)
16
+ super(path)
17
+ end
18
+
19
+ #
20
+ # See MEncoder#encode.
21
+ #
22
+ def self.encode(options={},&block)
23
+ self.create.encode(options,&block)
24
+ end
25
+
26
+ #
27
+ # Runs the +mencoder+ program with the given _options_ and the given
28
+ # _block_ with MEncoderTask.
29
+ #
30
+ def encode(options={},&block)
31
+ run_with_task(MEncoderTask.new(options,&block))
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,72 @@
1
+ require 'rtranscoder/mplayer/mplayer_common_task'
2
+
3
+ module RTranscoder
4
+ class MEncoderTask < MPlayerCommonTask
5
+
6
+ # Decoding/Filtering options
7
+ long_option :flag => '-ac', :name => :audio_codecs # TODO: add formating
8
+ long_option :flag => '-af-adv', :name => :advanced_audio_filtering # TODO: add formating
9
+ long_option :flag => '-afm', :name => :audio_codec_families # TODO: add formating
10
+ long_option :flag => '-aspect', :name => :aspect_ratio
11
+ long_option :flag => '-noaspect', :name => :disable_aspect_ratio
12
+ long_option :flag => '-field-dominance'
13
+ long_option :flag => '-flip'
14
+ long_option :flag => '-lavdopts', :name => :libavcodec # TODO: add formating
15
+ long_option :flag => '-noslices', :name => :disable_slices
16
+ long_option :flag => '-nosound', :name => :disable_sound
17
+ long_option :flag => '-novideo', :name => :disable_video
18
+ long_option :flag => '-pp', :name => :dll_postprocess_level
19
+ long_option :flag => '-pphelp', :name => :postprocess_help
20
+ long_option :flag => '-ssf', :name => :software_scaler
21
+ long_option :flag => '-stereo'
22
+ long_option :flag => '-sws', :name => :software_scaler_algorithm
23
+ long_option :flag => '-vc', :name => :video_codecs
24
+ long_option :flag => '-vfm', :name => :video_codec_families
25
+ long_option :flag => '-xvidopts', :name => :xvid_decoding
26
+
27
+ # General encoding options
28
+ long_option :flag => '-audio-delay'
29
+ long_option :flag => '-audio-density'
30
+ long_option :flag => '-audio-preload'
31
+ long_option :flag => '-fafmttag', :name => :audio_tag_format
32
+ long_option :flag => '-ffourcc', :name => :video_fourcc
33
+ long_option :flag => '-force-avi-aspect'
34
+ long_option :flag => '-hr-edl-seek', :name => :hires_edl_seek
35
+ long_option :flag => '-info' # TODO: add formating
36
+ long_option :flag => '-noautoexpand', :name => :disable_auto_expand
37
+ long_option :flag => '-noencodedups', :name => :ignore_duplicate_frames
38
+ long_option :flag => '-noodml', :name => :disable_open_dml_index
39
+ long_option :flag => '-noskip', :name => :disable_frame_skipping
40
+ short_option :flag => '-o', :name => :output
41
+ long_option :flag => '-oac', :name => :output_audio_codec
42
+ long_option :flag => '-of', :name => :output_container
43
+ long_option :flag => '-ofps', :name => :output_fps
44
+ long_option :flag => '-ovc', :name => :output_video_codec
45
+ long_option :flag => '-passlogfile', :name => :pass_log_file
46
+ long_option :flag => '-skiplimit', :name => :skip_limit
47
+ long_option :flag => '-vobsubout', :name => :vob_output_basename
48
+ long_option :flag => '-vobsuboutid', :name => :vob_output_subtitle_language
49
+ long_option :flag => '-vobsuboutindex', :name => :vob_output_subtitle_index
50
+
51
+ def self.codec_options(name)
52
+ long_option :flag => "-#{name}opts" # TODO: add formating
53
+ end
54
+
55
+ # Codec specific encoding options
56
+ codec_options :lavc
57
+ codec_options :xvidenc
58
+ codec_options :lame
59
+ codec_options :toolame
60
+ codec_options :twolame
61
+ codec_options :nuv
62
+ codec_options :xvfw
63
+ codec_options :faac
64
+ codec_options :x264enc
65
+ codec_options :mpeg
66
+ codec_options :lavf
67
+
68
+ non_option :leading => true, :name => :input
69
+ non_option :tailing => true, :name => :smb_output
70
+
71
+ end
72
+ end
@@ -0,0 +1,35 @@
1
+ require 'rtranscoder/mplayer/mplayer_task'
2
+ require 'rtranscoder/extensions'
3
+
4
+ require 'rprogram/program'
5
+
6
+ module RTranscoder
7
+ class MPlayer < RProgram::Program
8
+
9
+ name_program :mplayer
10
+
11
+ #
12
+ # Creates a new MPlayer object with the specified _path_ of the
13
+ # +mplayer+ program.
14
+ #
15
+ def initialize(path)
16
+ super(path)
17
+ end
18
+
19
+ #
20
+ # See MPlayer#play.
21
+ #
22
+ def self.play(options={},&block)
23
+ self.create.play(options,&block)
24
+ end
25
+
26
+ #
27
+ # Runs the +mplayer+ program with the given _options_ and the given
28
+ # _block_ using MPlayerTask.
29
+ #
30
+ def play(options={},&block)
31
+ run_with_task(MPlayerTask.new(options,&block))
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,89 @@
1
+ require 'rprogram/task'
2
+
3
+ module RTranscoder
4
+ class MPlayerCommonTask < RProgram::Task
5
+
6
+ # General options
7
+ long_option :flag => '-codecs-file'
8
+ long_option :flag => '-include'
9
+ long_option :flag => '-list-options'
10
+ long_option :flag => '-msgcharset', :name => :message_charset
11
+ long_option :flag => '-msglevel', :name => :message_verbose
12
+ long_option :flag => '-quiet'
13
+ long_option :flag => '-priority'
14
+ long_option :flag => '-profile'
15
+ long_option :flag => '-really-quiet'
16
+ long_option :flag => '-show-profile'
17
+ long_option :flag => '-use-filedir-conf'
18
+ short_option :flag => '-o', :name => :output
19
+ short_option :flag => '-v', :name => :verbose
20
+
21
+ # Demuxer/Stream options
22
+ long_option :flag => '-a52drc'
23
+ long_option :flag => '-aid', :name => :audio_channel
24
+ long_option :flag => '-alang', :name => :audio_language
25
+ long_option :flag => '-audio-demuxer'
26
+ long_option :flag => '-audiofile', :name => :audio_file
27
+ long_option :flag => '-audiofile-cache', :name => :audio_file_cache
28
+ long_option :flag => '-reuse-socket'
29
+ long_option :flag => '-bandwidth'
30
+ long_option :flag => '-cache'
31
+ long_option :flag => '-nocache'
32
+ long_option :flag => '-cache-min', :name => :cache_minimum
33
+ long_option :flag => '-cache-seek-min', :name => :cache_seek_minimum
34
+ long_option :flag => '-cdda'
35
+ long_option :flag => '-cdrom-device'
36
+ long_option :flag => '-channels'
37
+ long_option :flag => '-chapter'
38
+ long_option :flag => '-cookies'
39
+ long_option :flag => '-cookies-file'
40
+ long_option :flag => '-delay'
41
+ long_option :flag => '-ignore-start'
42
+ long_option :flag => '-demuxer'
43
+ long_option :flag => '-dvbin'
44
+ long_option :flag => '-dvd-device'
45
+ long_option :flag => '-dvd-speed'
46
+ long_option :flag => '-dvdangle', :name => :dvd_angle
47
+ long_option :flag => '-edl'
48
+ long_option :flag => '-endpos', :name => :end_position
49
+ long_option :flag => '-forceidx', :name => :force_index
50
+ long_option :flag => '-fps'
51
+ long_option :flag => '-frames'
52
+ long_option :flag => '-hr-mp3-seek', :name => :hires_mp3_seeking
53
+ long_option :flag => '-idx', :name => :index
54
+ long_option :flag => '-noidx', :name => :skip_index
55
+ long_option :flag => '-ipv4-only-proxy'
56
+ long_option :flag => '-loadidx', :name => :load_index
57
+ long_option :flag => '-mc' # TODO: add formating
58
+ long_option :flag => '-mf' # TODO: add formating
59
+ long_option :flag => '-ni', :name => :non_interleaved_avi_parser
60
+ long_option :flag => '-nobps', :name => :disable_bps
61
+ long_option :flag => '-noextbased', :name => :disable_ext_based_demuxer
62
+ long_option :flag => '-passwd', :name => :http_password
63
+ long_option :flag => '-prefer-ipv4'
64
+ long_option :flag => '-prefer-ipv6'
65
+ long_option :flag => '-psprobe', :name => :probe_into_stream
66
+ long_option :flag => '-pvr' # TODO: add formating
67
+ long_option :flag => '-radio' # TODO: add formating
68
+ long_option :flag => '-rawaudio', :name => :raw_audio # TODO: add formating
69
+ long_option :flag => '-rawvideo', :name => :raw_video # TODO: add formating
70
+ long_option :flag => '-rtsp-port'
71
+ long_option :flag => '-rtsp-destination'
72
+ long_option :flag => '-rtsp-stream-over-tcp'
73
+ long_option :flag => '-saveidx', :name => :save_index
74
+ long_option :flag => '-sb', :name => :seek_to_byte
75
+ long_option :flag => '-speed'
76
+ long_option :flag => '-srate', :name => :output_sample_rate
77
+ long_option :flag => '-ss', :name => :seek_to_time
78
+ long_option :flag => '-tskeepbroken', :name => :ignore_broken_ts_packets
79
+ long_option :flag => '-tsprobe', :name => :probe_into_ts_stream
80
+ long_option :flag => '-tsprog', :name => :ts_program
81
+ long_option :flag => '-tv' # TODO: add formating
82
+ long_option :flag => '-tvscan', :name => :tv_scan # TODO: add formating
83
+ long_option :flag => '-user', :name => :http_username
84
+ long_option :flag => '-user-agent', :name => :http_user_agent
85
+ long_option :flag => '-vid', :name => :video_channel
86
+ long_option :flag => '-vivo', :name => :vivo_audio_parameters
87
+
88
+ end
89
+ end
@@ -0,0 +1,52 @@
1
+ require 'rtranscoder/mplayer/mplayer_common_task'
2
+
3
+ module RTranscoder
4
+ class MPlayerTask < MPlayerCommonTask
5
+
6
+ # Player Options
7
+ long_option :flag => '-autoq', :name => :auto_quality
8
+ long_option :flag => '-autosync', :name => :auto_sync
9
+ long_option :flag => '-benchmark'
10
+ long_option :flag => '-colorkey', :name => :color_key
11
+ long_option :flag => '-nocolorkey', :name => :no_color_key
12
+ long_option :flag => '-correct-pts'
13
+ long_option :flag => '-crash-debug'
14
+ long_option :flag => '-doubleclick-time'
15
+ long_option :flag => '-edlout', :name => :edl_output
16
+ long_option :flag => '-enqueue'
17
+ long_option :flag => '-fixed-vo', :name => :fixed_video_output
18
+ long_option :flag => '-framedrop', :name => :frame_drop
19
+ long_option :flag => '-gui', :name => :enable_gui
20
+ long_option :flag => '-no-gui', :name => :disable_gui
21
+ long_option :flag => '--help'
22
+ long_option :flag => '-hardframedrop', :name => :hard_frame_drop
23
+ long_option :flag => '-identify'
24
+ long_option :flag => '-idle'
25
+ long_option :flag => '-input'
26
+ long_option :flag => '-key-fifo-size'
27
+ long_option :flag => '-lircconf', :name => :lirc_config
28
+ long_option :flag => '-list-properties'
29
+ long_option :flag => '-loop'
30
+ long_option :flag => '-menu'
31
+ long_option :flag => '-menu-cfg', :name => :menu_config
32
+ long_option :flag => '-menu-chroot'
33
+ long_option :flag => '-menu-keepdir', :name => :menu_keep_directory
34
+ long_option :flag => '-menu-root'
35
+ long_option :flag => '-menu-startup'
36
+ long_option :flag => '-mouse-movements'
37
+ long_option :flag => '-noconsolecontrols', :name => :disable_console_controls
38
+ long_option :flag => '-nojoystick', :name => :disable_joy_stick
39
+ long_option :flag => '-nolirc', :name => :disable_lirc
40
+ long_option :flag => '-nomouseinput', :name => :disable_mouse_input
41
+ long_option :flag => '-rtc'
42
+ long_option :flag => '-playing-msg', :name => :playing_message
43
+ long_option :flag => '-playlist'
44
+ long_option :flag => '-rtc-device'
45
+ long_option :flag => '-shuffle'
46
+ long_option :flag => '-skin'
47
+ long_option :flag => '-slave'
48
+ long_option :flag => '-softsleep', :name => :soft_sleep
49
+ long_option :flag => '-sstep', :name => :skip_step
50
+
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module RTranscoder
2
+ VERSION = '0.0.9'
3
+ end
File without changes
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rtranscoder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Hal Brodigan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-01-17 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rprogram
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.1.0
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: hoe
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.4.0
32
+ version:
33
+ description: "No more must one have to provide a shell command in order to run ffmpeg or mencoder for one's transcoding needs. RTranscoder and RProgram have mapped all the command-line options of various transcoding utilities to Ruby classes and methods for your convenience. == FEATURES/PROBLEMS: * Supports FFmpeg. * Supports MPlayer. * Supports MEncoder. == REQUIREMENTS: * RProgram"
34
+ email: postmodern.mod3@gmail.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - History.txt
41
+ - Manifest.txt
42
+ - README.txt
43
+ files:
44
+ - History.txt
45
+ - Manifest.txt
46
+ - README.txt
47
+ - Rakefile
48
+ - examples/encode_flv.rb
49
+ - examples/thumbnail.rb
50
+ - lib/rtranscoder.rb
51
+ - lib/rtranscoder/version.rb
52
+ - lib/rtranscoder/extensions.rb
53
+ - lib/rtranscoder/extensions/float.rb
54
+ - lib/rtranscoder/ffmpeg.rb
55
+ - lib/rtranscoder/ffmpeg/ffmpeg.rb
56
+ - lib/rtranscoder/ffmpeg/ffmpeg_task.rb
57
+ - lib/rtranscoder/ffmpeg/extensions.rb
58
+ - lib/rtranscoder/ffmpeg/extensions/integer.rb
59
+ - lib/rtranscoder/mplayer/mplayer_common_task.rb
60
+ - lib/rtranscoder/mplayer/mplayer.rb
61
+ - lib/rtranscoder/mplayer/mplayer_task.rb
62
+ - lib/rtranscoder/mplayer/mencoder.rb
63
+ - lib/rtranscoder/mplayer/mencoder_task.rb
64
+ - test/test_rtranscoder.rb
65
+ has_rdoc: true
66
+ homepage: " by Hal Brodigan"
67
+ post_install_message:
68
+ rdoc_options:
69
+ - --main
70
+ - README.txt
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ requirements: []
86
+
87
+ rubyforge_project: rtranscoder
88
+ rubygems_version: 1.0.1
89
+ signing_key:
90
+ specification_version: 2
91
+ summary: A Rubyful interface to various transcoding utilities using the RProgram library.
92
+ test_files:
93
+ - test/test_rtranscoder.rb