Class: MencoderWrapper
- Inherits:
-
Object
- Object
- MencoderWrapper
- Defined in:
- lib/mencoder_wrapper.rb
Defined Under Namespace
Classes: TimingError
Class Method Summary collapse
- .calculate_final_filename(to_here_final_file) ⇒ Object
-
.get_bat_commands(these_settings, this_drive, to_here_final_file, start_here = nil, end_here = nil, dvd_title_track = "1", delete_partials = false, require_deletion_entry = false) ⇒ Object
called from the UI…
- .get_header(this_drive, these_settings) ⇒ Object
- .get_section(start, endy, should_mute, to_here_final_file) ⇒ Object
Class Method Details
.calculate_final_filename(to_here_final_file) ⇒ Object
37 38 39 |
# File 'lib/mencoder_wrapper.rb', line 37 def calculate_final_filename to_here_final_file @big_temp = to_here_final_file + ".fulli_unedited.tmp.mpg" end |
.get_bat_commands(these_settings, this_drive, to_here_final_file, start_here = nil, end_here = nil, dvd_title_track = "1", delete_partials = false, require_deletion_entry = false) ⇒ Object
called from the UI…
42 43 44 45 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 |
# File 'lib/mencoder_wrapper.rb', line 42 def get_bat_commands these_settings, this_drive, to_here_final_file, start_here = nil, end_here = nil, dvd_title_track = "1", delete_partials = false, require_deletion_entry = false combined = EdlParser.convert_incoming_to_split_sectors these_settings @dvd_title_track = dvd_title_track assert dvd_title_track if start_here || end_here raise 'need both' unless end_here && start_here start_here = EdlParser.translate_string_to_seconds(start_here) end_here = EdlParser.translate_string_to_seconds(end_here) combined.select!{|start, endy, type| start > start_here && endy < end_here } raise TimingError.new("unable to find deletion entry between #{start_here} and #{end_here}") if require_deletion_entry && combined.length == 0 # it's relative now, since we rip from not the beginning previous_end = start_here else previous_end = 0 end calculate_final_filename to_here_final_file out = get_header this_drive, these_settings @idx = 0 combined.each {|start, endy, type| if start > previous_end out += get_section previous_end, start, false, to_here_final_file end # type is either mute or :blank or :mute if type == :blank # do nothing... clip will be skipped else out += get_section start, endy, true, to_here_final_file end previous_end = endy } out += get_section previous_end, end_here || 1_000_000, false, to_here_final_file partials = (1..@idx).map{|n| "#{to_here_final_file}.#{n}.avi"} to_here_final_file = to_here_final_file + ".avi" if File.exist? to_here_final_file FileUtils.rm to_here_final_file # raises on deletion failure...which is what we want I think...hopefully. end out += "call mencoder #{partials.join(' ')} -o #{to_here_final_file} -ovc copy -oac copy\n" out += "@rem old DISABLED join way... call mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=18:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 30000/1001 #{partials.join(' ')} -o #{to_here_final_file}\n" delete_prefix = ""#delete_partials ? "" : "@rem " out += "@rem del #{@big_temp}\n" # LODO no @rem out += "#{delete_prefix} del " + partials.join(' ') + "\n" out += "echo wrote (probably successfully) to #{to_here_final_file}" out end |
.get_header(this_drive, these_settings) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mencoder_wrapper.rb', line 26 def get_header this_drive, these_settings out = '' if File.exist?(@big_temp) && File.exist?(@big_temp + '.done') out = '@rem ' end audio_codec = these_settings['audio_codec'] || 'mp3lame' # not copy...sniff...or you can't hear cars... LODO # LODO do I need mp3lame for sintel, or can I get away with lavc? video_opts = "-vf scale=720:480,harddup -ovc lavc -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=1:vstrict=0:acodec=ac3:abitrate=192:autoaspect -ofps 30000/1001" out + "mencoder dvdnav://#{@dvd_title_track} -of mpeg -mpegopts format=dvd:tsaf -alang en -nocache -sid 1000 -oac #{audio_codec} #{video_opts} -o #{@big_temp} -dvd-device #{this_drive} && echo done_grabbing > #{@big_temp}.done\n" end |
.get_section(start, endy, should_mute, to_here_final_file) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/mencoder_wrapper.rb', line 89 def get_section start, endy, should_mute, to_here_final_file raise 'start == end' if start == endy # should never actually happen... # delete 0.001 as per wiki's suggestion. endy = endy - start - 0.001 # very decreased volume is like muting :) # LODO can we copy more here? ntsc-dvd supposedly remuxes... codecs = should_mute ? "-vcodec copy -acodec ac3 -vol 0 " : "-vcodec copy -acodec copy " # LODO the ac3 must match the other copy codec ? partial_filename = to_here_final_file + '.' + (@idx += 1).to_s + '.avi' if File.exist? partial_filename FileUtils.rm partial_filename end "ffmpeg -i #{@big_temp} #{codecs} -ss #{start} -t #{endy} #{partial_filename}\n" end |