Class: RFF::Processor
- Inherits:
-
Object
- Object
- RFF::Processor
- Defined in:
- lib/processor.rb
Overview
The main processing class of the rff gem. It spawns FFmpeg conversion process and parses its output, providing information about input and output files and current process status
Instance Method Summary collapse
-
#audio_input_bitrate2 ⇒ Object
This method returns bitrate of audio input (from input information line).
-
#audio_input_channelmode ⇒ Object
This method returns channel mode (eg. mono, stereo) of audio input.
-
#audio_input_format ⇒ Object
This method returns format of audio input.
-
#audio_input_format_type ⇒ Object
This method returns type of format of audio input.
-
#audio_input_frequency ⇒ Object
This method returns frequency of audio input.
-
#audio_input_metadata ⇒ Object
This method returns metadata for audio input stream as a hash with keys being symbols representing each metadata downcased name.
-
#audio_output_bitrate2 ⇒ Object
This method returns bitrate of audio output (from output information line).
-
#audio_output_channelmode ⇒ Object
This method returns channel mode (eg. mono, stereo) of audio output.
-
#audio_output_format ⇒ Object
This method returns format of audio output.
-
#audio_output_format_type ⇒ Object
This method returns type of format of audio output.
-
#audio_output_frequency ⇒ Object
This method returns frequency of audio output.
-
#audio_output_metadata ⇒ Object
This method returns metadata for audio output stream as a hash with keys being symbols representing each metadata downcased name.
-
#audio_stream_mapping ⇒ Object
This method returns audio stream mapping information (input_format -> output_format).
-
#command ⇒ Object
This method returns the FFmpeg command used for conversion.
-
#command_exit_status ⇒ Object
This method returns the exit status of the FFmpeg command.
-
#common_input_metadata ⇒ Object
This method returns common metadata for input streams as a hash with keys being symbols representing each metadata downcased name.
-
#common_output_metadata ⇒ Object
This method returns common metadata for output streams as a hash with keys being symbols representing each metadata downcased name.
-
#conversion_type ⇒ Object
This method returns conversion type (:audio or :video).
-
#custom_args ⇒ Object
This method returns custom arguments passed to FFmpeg.
-
#detected_output_type ⇒ Object
This method returns output type read by FFmpeg.
-
#ffmpeg_build_line ⇒ Object
This method returns FFmpeg build line.
-
#ffmpeg_version_line ⇒ Object
This method returns FFmpeg version line.
-
#fire ⇒ Object
This method runs the FFmpeg conversion process in a separate thread.
-
#format_processing_percentage ⇒ Object
This method returns percentage of process completion formatted for output.
-
#full_output_path ⇒ Object
This method returns full path to the output file.
-
#initialize(input, output_type, output_path = nil, quality = "5000k", custom_args = nil, recommended_audio_quality = true, disable_subtitles_decoding = true) ⇒ Processor
constructor
This constructor initializes the class with the following arguments: * input (required) - the full path to the input file * output_type (required) - defines the type of the output.
-
#input ⇒ Object
This method returns full input path.
-
#input_bitrate ⇒ Object
This method returns input bitrate (from the duration line).
-
#input_duration ⇒ Object
This method returns input duration.
-
#input_start ⇒ Object
This method returns start point of the input.
-
#input_type ⇒ Object
This method returns input type detected by FFmpeg.
-
#kill ⇒ Object
This method kills processing thread and sets status to :aborted.
-
#output_name ⇒ Object
This method returns full output name.
-
#output_path ⇒ Object
This method returns path where the output is (being) saved.
-
#output_type ⇒ Object
This method returns output type read from the filename.
-
#parser_status ⇒ Object
This method returns current output parser status.
-
#processing_percentage ⇒ Object
This method returns percentage of process completion.
-
#processing_status ⇒ Object
This method returns a hash which represents current processing status (eg. frames processed, time processed etc.) with keys being symbols representing each status value.
-
#quality ⇒ Object
This method returns used video quality.
-
#raw_command_output ⇒ Object
This method returns raw command output as an array of lines after getting rid of unneeded whitespaces.
-
#status ⇒ Object
This method returns current processing status (:pending, :processing, :completed, :failed, :aborted).
-
#video_input_additional ⇒ Object
This method returns additional information about video input as an array of values.
-
#video_input_colorspace ⇒ Object
This method returns color space of video input.
-
#video_input_format ⇒ Object
This method returns format of video input.
-
#video_input_metadata ⇒ Object
This method returns metadata for video input stream as a hash with keys being symbols representing each metadata downcased name.
-
#video_input_resolution ⇒ Object
This method returns resolution of video input.
-
#video_output_additional ⇒ Object
This method returns additional information about video output as an array of values.
-
#video_output_colorspace ⇒ Object
This method returns color space of video output.
-
#video_output_format ⇒ Object
This method returns format of video output.
-
#video_output_metadata ⇒ Object
This method returns metadata for video output stream as a hash with keys being symbols representing each metadata downcased name.
-
#video_output_resolution ⇒ Object
This method returns resolution of video output.
-
#video_stream_mapping ⇒ Object
This method returns video stream mapping information (input_format -> output_format).
Constructor Details
#initialize(input, output_type, output_path = nil, quality = "5000k", custom_args = nil, recommended_audio_quality = true, disable_subtitles_decoding = true) ⇒ Processor
This constructor initializes the class with the following arguments:
-
input (required) - the full path to the input file
-
output_type (required) - defines the type of the output. Must be one of [:mp3, :ogg, :wav] for audio conversion or [:mp4, :ogv, :webm] for video conversion
-
output_path - a path to place the output file in. Defaults to nil, which means that the input’ s directory path is used
-
quality - only affects video conversion. Sets the video conversion quality. Defaults to 5000k, which is tested value for good video conversion quality
-
custom_args - passes custom arguments to FFmpeg. Defaults to nil, which means no custom arguments are given
-
recommended_audio_quality - determines if recommended by FFmpeg community audio quality settings should be used. Defaults to true, which means audio conversion with good, recommended quality. Set to false if you are giving additional arguments that determine this quality.
-
disable_subtitles_decoding - in some formats subtitle decoding causes problems. This option disables this feature. Defaults to true to bypass problems by default.
This method also validates arguments, determines full output name, generates appropriate FFmpeg command, determines conversion type and initializes status (it is :pending at this point).
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/processor.rb', line 21 def initialize input, output_type, output_path=nil, quality="5000k", custom_args=nil, recommended_audio_quality=true, disable_subtitles_decoding=true if input.nil? || input.empty? || output_type.nil? raise RFF::ArgumentError.new("Input and output type can not be empty nor nil!") end if ![:mp3, :ogg, :wav, :mp4, :webm, :ogv].include?(output_type.to_sym) raise RFF::ArgumentError.new("Output type must be one of [:mp3, :ogg, :wav, :mp4, :webm, :ogv]!") end @input = input @output_type = output_type @output_name = File.basename(@input).split(".")[0] @output_path = output_path || File.dirname(input) @quality = quality @custom_args = custom_args if [:mp3, :ogg, :wav].include?(@output_type) @command = "ffmpeg -y -i " + '"' + "#{@input}" + '"' + " -acodec #{@output_type == :mp3 ? "libmp3lame" : (@output_type == :ogg ? "libvorbis" : "pcm_s16le")}#{recommended_audio_quality ? (@output_type == :mp3 ? " -aq 2" : (@output_type == :ogg ? " -aq 4" : "")) : ""}#{disable_subtitles_decoding ? " -sn" : ""}#{@custom_args.nil? ? "" : " #{@custom_args}"} " + '"' + "#{@output_path}/#{@output_name}.#{@output_type.to_s}" + '"' @conversion_type = :audio else @command = "ffmpeg -y -i " + '"' + "#{@input}" + '"' + " -acodec #{(@output_type == :webm || @output_type == :ogv) ? "libvorbis" : "aac"} -vcodec #{@output_type == :webm ? "libvpx" : (@output_type == :ogv ? "libtheora" : "mpeg4")}#{@output_type == :mp4 ? " -strict -2" : ""}#{([email protected]? && [email protected]?) ? " -b:v #{@quality}" : ""}#{recommended_audio_quality ? (@output_type == :webm || @output_type == :ogv ? " -aq 4" : " -b:a 240k") : ""}#{disable_subtitles_decoding ? " -sn" : ""}#{@custom_args.nil? ? "" : " #{@custom_args}"} " + '"' + "#{@output_path}/#{@output_name}.#{@output_type.to_s}" + '"' @conversion_type = :video end @status = :pending end |
Instance Method Details
#audio_input_bitrate2 ⇒ Object
This method returns bitrate of audio input (from input information line)
535 536 537 |
# File 'lib/processor.rb', line 535 def audio_input_bitrate2 @audio_input_bitrate2 end |
#audio_input_channelmode ⇒ Object
This method returns channel mode (eg. mono, stereo) of audio input
523 524 525 |
# File 'lib/processor.rb', line 523 def audio_input_channelmode @audio_input_channelmode end |
#audio_input_format ⇒ Object
This method returns format of audio input
511 512 513 |
# File 'lib/processor.rb', line 511 def audio_input_format @audio_input_format end |
#audio_input_format_type ⇒ Object
This method returns type of format of audio input
529 530 531 |
# File 'lib/processor.rb', line 529 def audio_input_format_type @audio_input_format_type end |
#audio_input_frequency ⇒ Object
This method returns frequency of audio input
517 518 519 |
# File 'lib/processor.rb', line 517 def audio_input_frequency @audio_input_freq end |
#audio_input_metadata ⇒ Object
This method returns metadata for audio input stream as a hash with keys being symbols representing each metadata downcased name
427 428 429 |
# File 'lib/processor.rb', line 427 def end |
#audio_output_bitrate2 ⇒ Object
This method returns bitrate of audio output (from output information line)
565 566 567 |
# File 'lib/processor.rb', line 565 def audio_output_bitrate2 @audio_output_bitrate2 end |
#audio_output_channelmode ⇒ Object
This method returns channel mode (eg. mono, stereo) of audio output
553 554 555 |
# File 'lib/processor.rb', line 553 def audio_output_channelmode @audio_output_channelmode end |
#audio_output_format ⇒ Object
This method returns format of audio output
541 542 543 |
# File 'lib/processor.rb', line 541 def audio_output_format @audio_output_format end |
#audio_output_format_type ⇒ Object
This method returns type of format of audio output
559 560 561 |
# File 'lib/processor.rb', line 559 def audio_output_format_type @audio_output_format_type end |
#audio_output_frequency ⇒ Object
This method returns frequency of audio output
547 548 549 |
# File 'lib/processor.rb', line 547 def audio_output_frequency @audio_output_freq end |
#audio_output_metadata ⇒ Object
This method returns metadata for audio output stream as a hash with keys being symbols representing each metadata downcased name
445 446 447 |
# File 'lib/processor.rb', line 445 def end |
#audio_stream_mapping ⇒ Object
This method returns audio stream mapping information (input_format -> output_format)
463 464 465 |
# File 'lib/processor.rb', line 463 def audio_stream_mapping @stream_mapping_audio end |
#command ⇒ Object
This method returns the FFmpeg command used for conversion
379 380 381 |
# File 'lib/processor.rb', line 379 def command @command end |
#command_exit_status ⇒ Object
This method returns the exit status of the FFmpeg command
631 632 633 |
# File 'lib/processor.rb', line 631 def command_exit_status @exit_status end |
#common_input_metadata ⇒ Object
This method returns common metadata for input streams as a hash with keys being symbols representing each metadata downcased name
421 422 423 |
# File 'lib/processor.rb', line 421 def end |
#common_output_metadata ⇒ Object
This method returns common metadata for output streams as a hash with keys being symbols representing each metadata downcased name
439 440 441 |
# File 'lib/processor.rb', line 439 def end |
#conversion_type ⇒ Object
This method returns conversion type (:audio or :video)
391 392 393 |
# File 'lib/processor.rb', line 391 def conversion_type @conversion_type end |
#custom_args ⇒ Object
This method returns custom arguments passed to FFmpeg
385 386 387 |
# File 'lib/processor.rb', line 385 def custom_args @custom_args end |
#detected_output_type ⇒ Object
This method returns output type read by FFmpeg
355 356 357 |
# File 'lib/processor.rb', line 355 def detected_output_type @detected_output_type end |
#ffmpeg_build_line ⇒ Object
This method returns FFmpeg build line
481 482 483 |
# File 'lib/processor.rb', line 481 def ffmpeg_build_line @ff_buildline end |
#ffmpeg_version_line ⇒ Object
This method returns FFmpeg version line
475 476 477 |
# File 'lib/processor.rb', line 475 def ffmpeg_version_line @ff_versionline end |
#fire ⇒ Object
This method runs the FFmpeg conversion process in a separate thread. First it initializes processing percentage and then spawns a new thread, in which FFmpeg conversion process is spawned through Open3.popen2e. It sets the processing status, passes the command output to OutputReader instance and initializes all the needed structures for information. Then it parses the output until it ends to extract the information, which is available through this class’ getter methods. All the information is filled in as soon as it appears in the command output. When the process finishes, it cleans up the streams, sets percentage to 100% and gets the command’ s exit status. Then it sets :completed or :failed status according to the command’ s status. At the end it catches and displays any exceptions that can occur in the thread
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/processor.rb', line 46 def fire @processing_percentage = 0 @processing_thread = Thread.new do |th| begin Open3.popen2e(@command) do |progin, progout, progthread| @status = :processing @parser_status = :normal outputreader = OutputReader.new(progout) @rawoutput = [] = {} = {} = {} = {} = {} = {} @processing_status = {} begin #puts "DEBUG: Processing next line..." line = outputreader.gets(["\n", "\r"]) line = line.chomp! if !line.nil? #puts "DEBUG: Line: " + line.to_s #puts "DEBUG: Raw OutputReader buffer content: " #puts outputreader.get_raw_buffer if !line.nil? && line != "EOF" #puts "DEBUG: Adding line to rawoutput..." @rawoutput << line # Getting rid of unnecessary indentation spaces #puts "DEBUG: Removing unnecessary spaces..." if line[/^[ ]+/] != nil line[/^[ ]+/] = "" end if line[/[ ]+/] != nil line[/[ ]+/] = " " end if line[/[ ]+$/] != nil line[/[ ]+$/] = "" end line.gsub!(/=[ ]+/, "=") # Parsing #puts "DEBUG: Line after spaces removal: " + line.to_s #puts "DEBUG: Parsing line..." if @conversion_type == :audio if @parser_status == :meta #puts "DEBUG: Parser in metadata parsing mode" if line[0..7] == "Duration" || line[0..5] == "Stream" || line[0] == "[" || line[0..5] == "Output" || line[0..4] == "Input" @parser_status = :normal else #puts "DEBUG: Reading metadata line..." if @last_met_io == :input [line.split(":")[0].downcase[0..-2].to_sym] = line.split(":")[1][1..-1] if !line.split(":")[0].nil? elsif @last_met_io == :output [line.split(":")[0].downcase[0..-2].to_sym] = line.split(":")[1][1..-1] if !line.split(":")[0].nil? end end end if @parser_status == :strmap #puts "DEBUG: Parser in stream mapping parsing mode" #puts "DEBUG: Reading stream mapping information..." @stream_mapping_audio = line[21..-2] @parser_status = :retnormal end if @parser_status == :normal #puts "DEBUG: Parser in normal mode" if line[0..5] == "ffmpeg" #puts "DEBUG: Approached version line" @ff_versionline = line elsif line[0..4] == "built" #puts "DEBUG: Approached build line" @ff_buildline = line elsif line[0..4] == "Input" #puts "DEBUG: Approached input declaration" @input_type = line.split(",")[1][1..-1] @last_met_io = :input elsif line[0..5] == "Output" #puts "DEBUG: Approached output declaration" @detected_output_type = line.split(",")[1][1..-1] @last_met_io = :output elsif line == "Metadata:" #puts "DEBUG: Approached metadata start" @parser_status = :meta elsif line[0..7] == "Duration" #puts "DEBUG: Approached duration line" @input_duration = line.split(",")[0][10..-1] if line.split(",")[1][1..5] == "start" #puts "DEBUG: Detected start variation of the line" @input_start = line.split(",")[1][6..-1] @input_bitrate = line.split(",")[2][10..-1] else #puts "DEBUG: Detected only bitrate variation of the line" @input_bitrate = line.split(",")[1][10..-1] end elsif line == "Stream mapping:" #puts "DEBUG: Approached stream mapping declaration" @parser_status = :strmap elsif line[0..5] == "Stream" #puts "DEBUG: Approached stream information line" if @last_met_io == :input @audio_input_format = line.split(",")[0][20..-1] @audio_input_freq = line.split(",")[1][1..-1] @audio_input_channelmode = line.split(",")[2][1..-1] @audio_input_format_type = line.split(",")[3][1..-1] if line.split(",")[4] != nil @audio_input_bitrate2 = line.split(",")[4][1..-1] end elsif @last_met_io == :output @audio_output_format = line.split(",")[0][20..-1] @audio_output_freq = line.split(",")[1][1..-1] @audio_output_channelmode = line.split(",")[2][1..-1] @audio_output_format_type = line.split(",")[3][1..-1] if line.split(",")[4] != nil @audio_output_bitrate2 = line.split(",")[4][1..-1] end end elsif line[0..3] == "size" #puts "DEBUG: Approached processing status line" line.split(" ").each do |spl| @processing_status[spl.split("=")[0].to_sym] = spl.split("=")[1] end if @processing_status[:time] != nil && @input_duration != nil @processing_percentage = ((((Time.parse(@processing_status[:time])-Time.parse("0:0"))/(Time.parse(@input_duration)-Time.parse("0:0")))).round(2)*100).to_i #/ This is for jEdit syntax highlighting to fix end end end if @parser_status == :retnormal #puts "DEBUG: Parser returning to normal mode" @parser_status = :normal end elsif @conversion_type == :video if @parser_status == :meta #puts "DEBUG: Parser in metadata parsing mode" if line[0..7] == "Duration" || line[0..5] == "Stream" || line[0] == "[" || line[0..5] == "Output" || line[0..4] == "Input" @parser_status = :normal else #puts "DEBUG: Reading metadata line..." name = line.split(":")[0] if !name.nil? name = name.downcase[0..-2].to_sym else #puts "DEBUG: Skipping because of nil name..." next end #puts "DEBUG: Name: #{name}" value = line.split(":")[1] if value.nil? value = "" else value = value[1..-1] end #puts "DEBUG: Value: #{value}" if @last_met_io == :input if @last_stream_type == nil [name] = value elsif @last_stream_type == :audio [name] = value elsif @last_stream_type == :video [name] = value end elsif @last_met_io == :output if @last_stream_type == nil [name] = value elsif @last_stream_type == :audio [name] = value elsif @last_stream_type == :video [name] = value end end end end if @parser_status == :strmap #puts "DEBUG: Parser in stream mapping parsing mode" #puts "DEBUG: Reading stream mapping information..." @stream_mapping_video = line[21..-2] @parser_status = :strmap2 elsif @parser_status == :strmap2 @stream_mapping_audio = line[21..-2] @parser_status = :retnormal end if @parser_status == :normal #puts "DEBUG: Parser in normal mode" if line[0..5] == "ffmpeg" #puts "DEBUG: Approached version line" @ff_versionline = line elsif line[0..4] == "built" #puts "DEBUG: Approached build line" @ff_buildline = line elsif line[0..4] == "Input" #puts "DEBUG: Approached input declaration" @input_type = line.split(",")[1][1..-1] @last_met_io = :input @last_stream_type = nil elsif line[0..5] == "Output" #puts "DEBUG: Approached output declaration" @detected_output_type = line.split(",")[1][1..-1] @last_met_io = :output @last_stream_type = nil elsif line == "Metadata:" #puts "DEBUG: Approached metadata start" @parser_status = :meta elsif line[0..7] == "Duration" #puts "DEBUG: Approached duration line" @input_duration = line.split(",")[0][10..-1] if line.split(",")[1][1..5] == "start" #puts "DEBUG: Detected start variation of the line" @input_start = line.split(",")[1][8..-1] @input_bitrate = line.split(",")[2][10..-1] else #puts "DEBUG: Detected only bitrate variation of the line" @input_bitrate = line.split(",")[1][10..-1] end elsif line == "Stream mapping:" #puts "DEBUG: Approached stream mapping declaration" @parser_status = :strmap elsif line[0..5] == "Stream" #puts "DEBUG: Approached stream information line" if line[13..17] == "Video" @last_stream_type = :video elsif line[13..17] == "Audio" @last_stream_type = :audio else @last_stream_type = nil end if @last_met_io == :input if @last_stream_type == :video @video_input_format = line.split(",")[0][20..-1] @video_input_colorspace = line.split(",")[1][1..-1] @video_input_resolution = line.split(",")[2][1..-1] @video_input_additional = line.split(",")[3..-1] elsif @last_stream_type == :audio @audio_input_format = line.split(",")[0][20..-1] @audio_input_freq = line.split(",")[1][1..-1] @audio_input_channelmode = line.split(",")[2][1..-1] @audio_input_format_type = line.split(",")[3][1..-1] if line.split(",")[4] != nil @audio_input_bitrate2 = line.split(",")[4][1..-1] end end elsif @last_met_io == :output if @last_stream_type == :video @video_output_format = line.split(",")[0][20..-1] @video_output_colorspace = line.split(",")[1][1..-1] @video_output_resolution = line.split(",")[2][1..-1] @video_output_additional = line.split(",")[3..-1] elsif @last_stream_type == :audio @audio_output_format = line.split(",")[0][20..-1] @audio_output_freq = line.split(",")[1][1..-1] @audio_output_channelmode = line.split(",")[2][1..-1] @audio_output_format_type = line.split(",")[3][1..-1] if line.split(",")[4] != nil @audio_output_bitrate2 = line.split(",")[4][1..-1] end end end elsif line[0..4] == "frame" #puts "DEBUG: Approached processing status line" line.split(" ").each do |spl| @processing_status[spl.split("=")[0].to_sym] = spl.split("=")[1] end if @processing_status[:time] != nil && @processing_status[:time] != "N/A" && @input_duration != nil && @input_duration != "N/A" @processing_percentage = ((((Time.parse(@processing_status[:time])-Time.parse("0:0"))/(Time.parse(@input_duration)-Time.parse("0:0")))).round(2)*100).to_i #/ This is for jEdit syntax highlighting to fix end end end if @parser_status == :retnormal #puts "DEBUG: Parser returning to normal mode" @parser_status = :normal end end end end while line != "EOF" #puts "DEBUG: After EOF, closing streams..." progout.close progin.close progthread.join progst = progthread.value @exit_status = progst.exitstatus #puts "Got output status: #{progst.exitstatus}" if progst.success? @status = :completed @processing_percentage = 100 else @status = :failed end end if @status == :failed raise RFF::ProcessingFailure.new(@exit_status, "Inspect the output as FFmpeg returned with status: ") end rescue => e puts "Caught exception: " + e.to_s puts "Backtrace:" puts e.backtrace @status = :failed end end end |
#format_processing_percentage ⇒ Object
This method returns percentage of process completion formatted for output
625 626 627 |
# File 'lib/processor.rb', line 625 def format_processing_percentage @processing_percentage.nil? ? "0%" : @processing_percentage.to_s + "%" end |
#full_output_path ⇒ Object
This method returns full path to the output file
397 398 399 |
# File 'lib/processor.rb', line 397 def full_output_path "#{@output_path}/#{@output_name}.#{@output_type.to_s}" end |
#input ⇒ Object
This method returns full input path
343 344 345 |
# File 'lib/processor.rb', line 343 def input @input end |
#input_bitrate ⇒ Object
This method returns input bitrate (from the duration line)
505 506 507 |
# File 'lib/processor.rb', line 505 def input_bitrate @input_bitrate end |
#input_duration ⇒ Object
This method returns input duration
493 494 495 |
# File 'lib/processor.rb', line 493 def input_duration @input_duration end |
#input_start ⇒ Object
This method returns start point of the input
499 500 501 |
# File 'lib/processor.rb', line 499 def input_start @input_start end |
#input_type ⇒ Object
This method returns input type detected by FFmpeg
487 488 489 |
# File 'lib/processor.rb', line 487 def input_type @input_type end |
#kill ⇒ Object
This method kills processing thread and sets status to :aborted
637 638 639 640 |
# File 'lib/processor.rb', line 637 def kill @processing_thread.kill @status = :aborted end |
#output_name ⇒ Object
This method returns full output name
361 362 363 |
# File 'lib/processor.rb', line 361 def output_name @output_name end |
#output_path ⇒ Object
This method returns path where the output is (being) saved
367 368 369 |
# File 'lib/processor.rb', line 367 def output_path @output_path end |
#output_type ⇒ Object
This method returns output type read from the filename
349 350 351 |
# File 'lib/processor.rb', line 349 def output_type @output_type end |
#parser_status ⇒ Object
This method returns current output parser status
415 416 417 |
# File 'lib/processor.rb', line 415 def parser_status @parser_status end |
#processing_percentage ⇒ Object
This method returns percentage of process completion
619 620 621 |
# File 'lib/processor.rb', line 619 def processing_percentage @processing_percentage || 0 end |
#processing_status ⇒ Object
This method returns a hash which represents current processing status (eg. frames processed, time processed etc.) with keys being symbols representing each status value
457 458 459 |
# File 'lib/processor.rb', line 457 def processing_status @processing_status end |
#quality ⇒ Object
This method returns used video quality
373 374 375 |
# File 'lib/processor.rb', line 373 def quality @quality end |
#raw_command_output ⇒ Object
This method returns raw command output as an array of lines after getting rid of unneeded whitespaces
403 404 405 |
# File 'lib/processor.rb', line 403 def raw_command_output @rawoutput end |
#status ⇒ Object
This method returns current processing status (:pending, :processing, :completed, :failed, :aborted)
409 410 411 |
# File 'lib/processor.rb', line 409 def status @status end |
#video_input_additional ⇒ Object
This method returns additional information about video input as an array of values
589 590 591 |
# File 'lib/processor.rb', line 589 def video_input_additional @video_input_additional end |
#video_input_colorspace ⇒ Object
This method returns color space of video input
577 578 579 |
# File 'lib/processor.rb', line 577 def video_input_colorspace @video_input_colorspace end |
#video_input_format ⇒ Object
This method returns format of video input
571 572 573 |
# File 'lib/processor.rb', line 571 def video_input_format @video_input_format end |
#video_input_metadata ⇒ Object
This method returns metadata for video input stream as a hash with keys being symbols representing each metadata downcased name
433 434 435 |
# File 'lib/processor.rb', line 433 def end |
#video_input_resolution ⇒ Object
This method returns resolution of video input
583 584 585 |
# File 'lib/processor.rb', line 583 def video_input_resolution @video_input_resolution end |
#video_output_additional ⇒ Object
This method returns additional information about video output as an array of values
613 614 615 |
# File 'lib/processor.rb', line 613 def video_output_additional @video_output_additional end |
#video_output_colorspace ⇒ Object
This method returns color space of video output
601 602 603 |
# File 'lib/processor.rb', line 601 def video_output_colorspace @video_output_colorspace end |
#video_output_format ⇒ Object
This method returns format of video output
595 596 597 |
# File 'lib/processor.rb', line 595 def video_output_format @video_output_format end |
#video_output_metadata ⇒ Object
This method returns metadata for video output stream as a hash with keys being symbols representing each metadata downcased name
451 452 453 |
# File 'lib/processor.rb', line 451 def end |
#video_output_resolution ⇒ Object
This method returns resolution of video output
607 608 609 |
# File 'lib/processor.rb', line 607 def video_output_resolution @video_output_resolution end |
#video_stream_mapping ⇒ Object
This method returns video stream mapping information (input_format -> output_format)
469 470 471 |
# File 'lib/processor.rb', line 469 def video_stream_mapping @stream_mapping_video end |