Class: MencoderWrapper
- Inherits:
-
Object
- Object
- MencoderWrapper
- Defined in:
- lib/mencoder_wrapper.rb
Defined Under Namespace
Classes: TimingError
Class Method Summary collapse
- .am_on_developer_machine? ⇒ Boolean
- .calculate_fulli_filename(to_here_final_file) ⇒ Object
-
.get_bat_commands(these_settings, this_from_file, 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_file, these_settings) ⇒ Object
- .get_section(start, endy, should_mute, to_here_final_file) ⇒ Object
Class Method Details
.am_on_developer_machine? ⇒ Boolean
104 105 106 |
# File 'lib/mencoder_wrapper.rb', line 104 def am_on_developer_machine? Socket.gethostname =~ /roger|pack/i end |
.calculate_fulli_filename(to_here_final_file) ⇒ Object
43 44 45 |
# File 'lib/mencoder_wrapper.rb', line 43 def calculate_fulli_filename to_here_final_file @big_temp_fulli = to_here_final_file + ".fulli_unedited.tmp.mpg" end |
.get_bat_commands(these_settings, this_from_file, 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… only for transcoding.
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 |
# File 'lib/mencoder_wrapper.rb', line 49 def get_bat_commands these_settings, this_from_file, to_here_final_file, start_here = nil, end_here = nil, dvd_title_track = "1", delete_partials = false, require_deletion_entry = false dvd_start_offset = these_settings['dvd_start_offset'] # assume we prefer DVD timings which...we do :P raise 'EDL must have a dvd_start_offset, even if just 0.0 (or better yet, 0.28 is a common one), as we use this to translate from DVD to file times' unless dvd_start_offset dvd_start_offset = EdlParser.translate_string_to_seconds(dvd_start_offset) combined = EdlParser.convert_incoming_to_split_sectors these_settings, 0, dvd_start_offset, [], dvd_start_offset @dvd_title_track = dvd_title_track assert dvd_title_track if start_here || end_here raise 'need both end and start' 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_fulli_filename to_here_final_file out = get_header this_from_file, 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 } # trailer 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 p 'warning, overwriting+deleting previous ' + to_here_final_file FileUtils.rm to_here_final_file # raises on deletion failure...which is what we want I think...typically...early warning... end out += "mencoder #{partials.join(' ')} -o #{to_here_final_file} -ovc copy -oac copy\n" out += "@rem old DISABLED join way... 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 " delete_prefix = "@rem" if am_on_developer_machine? # for ease of double checking... out += "#{delete_prefix} del #{@big_temp_fulli}\n" out += "#{delete_prefix} del " + partials.join(' ') + "\n" out += "echo wrote (probably successfully) to #{to_here_final_file}" out end |
.get_header(this_file, these_settings) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mencoder_wrapper.rb', line 26 def get_header this_file, these_settings out = '' if File.exist?(@big_temp_fulli) && File.exist?(@big_temp_fulli + '.done') out = '@rem ' # don't re-do this file if .done file already exists... 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? will it work overall currently? # -vf pullup,softskip "fixes" freaky mixed DVD's, or so they tell me... # harddup is "to create a DVD compliant" video which...I think I don't need...but DVD players require it... # "This will result in a slightly bigger file, but will not cause problems when demuxing or remuxing into other container formats." LODO no harddup ok ??? # lodo: can I use ffmpeg to unmux-ify/GOP'ify perhaps? # LODO 24000/1001 ? # -vf pullup,softskip for DVD's that mix progressive and something something [some of them]...whatever it even really means :P video_opts = "-vf scale=720:480,pullup,softskip,harddup -forceidx -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 \"#{this_file.gsub('"', '\\"')}\" -of mpeg -mpegopts format=dvd:tsaf -alang en -nocache -sid 1000 -oac #{audio_codec} #{video_opts} -o #{@big_temp_fulli} -dvd-device #{this_file} && echo done_grabbing > #{@big_temp_fulli}.done\n" end |
.get_section(start, endy, should_mute, to_here_final_file) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/mencoder_wrapper.rb', line 108 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_fulli} #{codecs} -ss #{start} -t #{endy} #{partial_filename}\n" end |