sensible-cinema 0.34.0 → 0.35.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.gitmodules +1 -1
  2. data/README.TXT +19 -20
  3. data/Rakefile +191 -195
  4. data/TODO +122 -149
  5. data/VERSION +1 -1
  6. data/bin/sensible-cinema +52 -52
  7. data/change_log_with_feature_list.txt +532 -481
  8. data/documentation/troubleshooting.txt +3 -9
  9. data/go.bat +2 -2
  10. data/go.sh +1 -0
  11. data/goc.bat +1 -1
  12. data/goc.sh +1 -0
  13. data/lib/check_installed_mac.rb +2 -10
  14. data/lib/edl_parser.rb +40 -16
  15. data/lib/gui/base.rb +85 -27
  16. data/lib/gui/create-file.rb +3 -2
  17. data/lib/gui/create.rb +118 -101
  18. data/lib/gui/dependencies.rb +110 -76
  19. data/lib/gui/normal.rb +32 -81
  20. data/lib/mplayer_edl.rb +7 -1
  21. data/lib/subtitle_profanity_finder.rb +10 -5
  22. data/notes_for_potential_developers.txt +18 -25
  23. data/spec/bad_beginning.srt +3778 -0
  24. data/spec/edl_parser.spec.rb +4 -0
  25. data/spec/notes +327 -167
  26. data/spec/youtube_edl.spec.rb +28 -0
  27. data/template_bats/RUN SENSIBLE CINEMA CLICK HERE WINDOWS.bat +2 -2
  28. data/todo.inventionzy.txt +3 -1
  29. data/vendor/mplayer_patches/how_to_doze.bat +6 -0
  30. data/vendor/mplayer_patches/port_dir/PortIndex.quick +1 -1
  31. data/vendor/mplayer_patches/port_dir/how_to +16 -9
  32. data/vendor/mplayer_patches/port_dir/multimedia/mplayer-edl/Portfile +10 -25
  33. data/vendor/mplayer_patches/port_dir/multimedia/rdp-projects/Portfile +2 -2
  34. data/vendor/mplayer_patches/{configure_from_betterlogic → port_dir_is_for_mac} +0 -0
  35. data/www/content_editor.html +9 -5
  36. data/zamples/edit_decision_lists/dvds/big_buck_bunny_dvd.txt +7 -4
  37. data/zamples/edit_decision_lists/dvds/court_jester.txt +0 -1
  38. data/zamples/edit_decision_lists/dvds/edls_being_edited/father_goose.txt +41 -0
  39. data/zamples/edit_decision_lists/dvds/edls_being_edited/harry_potter_and_the_goblet_of_fire.txt +45 -0
  40. data/zamples/edit_decision_lists/dvds/edls_being_edited/national_treasure.txt +6 -3
  41. data/zamples/edit_decision_lists/dvds/edls_being_edited/percy_jackson_lightening_thief.txt +40 -0
  42. data/zamples/edit_decision_lists/dvds/edls_being_edited/percy_jackson_lightening_thief_mute_scary.txt +23 -0
  43. data/zamples/edit_decision_lists/dvds/edls_being_edited/puss_in_boots.txt +33 -0
  44. data/zamples/edit_decision_lists/dvds/edls_being_edited/ratatouille.txt +5 -5
  45. data/zamples/edit_decision_lists/dvds/edls_being_edited/rio.txt +24 -0
  46. data/zamples/edit_decision_lists/dvds/sintel_open_source_blender_ntsc_dvd.txt +0 -1
  47. metadata +17 -15
  48. data/lib/count_down_timer_jruby_swing.rb +0 -55
  49. data/vendor/mplayer_patches/apply.bat +0 -12
  50. data/vendor/mplayer_patches/libdvdnav/2905259c3b45529b3d8dedba572b6e4f67a2d8f4.diff +0 -19
  51. data/vendor/mplayer_patches/libdvdnav/83f1c9256f500285e46f1e44bcc74ffce90159db.diff +0 -16
  52. data/vendor/mplayer_patches/libdvdnav/eb91fb74680d30322461a1b9e425918ad4e2b2df.diff +0 -21
  53. data/vendor/mplayer_patches/libdvdnav/jump_to_time.diff +0 -654
  54. data/vendor/mplayer_patches/libdvdnav/non_strict.diff +0 -13
  55. data/vendor/mplayer_patches/mplayer_edl.diff +0 -354
  56. data/vendor/mplayer_patches/updated_lib_too +0 -0
@@ -1,12 +1,7 @@
1
1
  == Troubleshooting ==
2
-
3
- Problem: disk (or VOB folder) hangs on a "skip" segment.
4
- A. Known problem, just use the right arrow to skip past the problem section for now.
5
2
 
6
3
  Problem: disk (or VOB folder) just never play. Nothing happens, smplayer is just blank.
7
- Try to playback your DVD in "VLC Media Player" first, then try it again. Also check the "mplayer logs" and report back
8
- as a bug report.
9
-
4
+ Try to playback your DVD in "VLC Media Player" first, then try it again. Also check the "mplayer logs" and report this occurrence as a bug report.
10
5
 
11
6
  General trouble shooting:
12
7
 
@@ -24,9 +19,8 @@ You try to play back a sensible cinema-ized video file and it plays back without
24
19
  This probably means you're using windows media player, and don't have "codecs" installed
25
20
  to handle this type of audio. Not to fear, just download the "ffdshow tryouts" (google for it)
26
21
  and, when it gives you the option, be sure to check "mpeg2 video" and then
27
- it should "just work." You could also optionally just play the file in VLC Media Player or smplayer
28
- (there's a button for that). Installing "AC3Filter" may help if you can hear no audio.
29
- Really VLC Media Player is your best bet though.
22
+ it should "just work." You could also optionally just play the file in VLC Media Player or smplayer instead. Installing "AC3Filter" may help if you can hear no audio.
23
+ Really VLC Media Player is your best bet overall.
30
24
 
31
25
  If the end result video is too grainy/pixelated or if the overall process is too slow, let me know and I'll work on
32
26
  making it better. No really, I have some ideas, but want to see if there's need first for improvement in those areas.
data/go.bat CHANGED
@@ -1,2 +1,2 @@
1
- @rem NB that you can call it like go --debug
2
- call j %* bin\sensible-cinema
1
+ @rem NB that you can call it like go --debug
2
+ call j --1.8 %* bin\sensible-cinema
data/go.sh ADDED
@@ -0,0 +1 @@
1
+ j -J-Xdock:name="Sensible Cinema" -J-Xdock:icon="vendor/profs.png" bin/sensible-cinema $1 $2 $3 $4 $5
data/goc.bat CHANGED
@@ -1 +1 @@
1
- call j %* bin\sensible-cinema --create-mode --developer-mode
1
+ call j --1.8 %* bin\sensible-cinema --create-mode --developer-mode
data/goc.sh ADDED
@@ -0,0 +1 @@
1
+ j -J-Xdock:name="Sensible Cinema" -J-Xdock:icon="vendor/profs.png" bin/sensible-cinema $1 $2 $3 $4 $5 --create-mode
@@ -18,21 +18,13 @@ module CheckInstalledMac
18
18
  end
19
19
  end
20
20
 
21
- if name == 'mplayer'
22
- unless File.exist?('/opt/rdp_project_local/bin/mplayer')
23
- puts "please install mplayer edl, please install mplayer-edl, see website http://rogerdpack.t28.net/sensible-cinema/content_editor.html"
24
- return false
25
- end
26
- return true
27
- end
28
-
29
21
  # check for the others generically
30
22
 
31
- command = {"gocr" => "gocr --help", "convert" => "convert --help", "ffmpeg" => "ffmpeg -version"}[name]
23
+ command = {"gocr" => "gocr --help", "convert" => "convert --help", "ffmpeg" => "ffmpeg -version", "mplayer" => "mplayer"}[name]
32
24
 
33
25
  raise 'unknown ' + name unless command # sanity check
34
26
 
35
- unless system(command + " 1> " + OS.dev_null + " 2>" + OS.dev_null)
27
+ unless system("/opt/rdp_project_local/bin/#{command} 1>/dev/null 2>&1")
36
28
  name = 'ImageMagick' if name == 'convert' # special case...
37
29
  puts 'lacking dependency! Please install ' + name + ' by installing the contrib pkg from the website'
38
30
  false
@@ -20,6 +20,29 @@ require 'sane'
20
20
  require_relative 'convert_thirty_fps'
21
21
 
22
22
  class EdlParser
23
+
24
+ def self.on_any_file_changed_single_cached_thread &this_block
25
+ raise unless this_block
26
+ get_files_hash = proc {
27
+ glob = EDL_DIR + '/../**/*'
28
+ Dir[glob].map{|f|
29
+ [f, File.mtime(f)]
30
+ }.sort
31
+ }
32
+ old_value = get_files_hash.call
33
+ @@checking_thread ||= Thread.new {
34
+ loop {
35
+ current_value = get_files_hash.call
36
+ if current_value != old_value
37
+ print 'detected some file was changed! Re-parsing to update...'
38
+ old_value = current_value
39
+ this_block.call
40
+ puts 'done.'
41
+ end
42
+ sleep 2 # 0.02 for size 70, so...hopefully this is ok...
43
+ }
44
+ }
45
+ end
23
46
 
24
47
  # this one is 1:01:02.0 => 36692.0
25
48
  # its reverse is this: translate_time_to_human_readable
@@ -135,14 +158,15 @@ class EdlParser
135
158
  end
136
159
  rescue Exception => e
137
160
  string.strip.lines.to_a[0..-3].each_with_index{|l, idx| # last line doesn't need a comma check
138
- orig_line = l
139
- l = l.split('#')[0]
140
- l = l.strip
141
- unless l.empty?
142
- # todo strip off # comments at the end of lines too...
143
- end_char = l[-1..-1]
144
- if !end_char.in? [']', '[', '{'] # these are probably all ok...
145
- puts "warning: line #{idx} might be bad: (maybe needs comma after?) " + l unless end_char == ','
161
+ orig_line = l
162
+ l = l.split('#')[0]
163
+ l = l.strip
164
+
165
+ unless l.empty?
166
+ # todo strip off # comments at the end of lines too...
167
+ end_char = l[-1..-1]
168
+ if !end_char.in? ['[', '{'] # these are probably ok...
169
+ puts "warning: #{File.basename filename} line #{idx} might be bad: (maybe needs comma after?) " + l unless end_char == ','
146
170
  end
147
171
  end
148
172
  }
@@ -221,30 +245,30 @@ class EdlParser
221
245
  raise if add_this_to_all_ends < 0
222
246
  raise if subtract_this_from_ends < 0
223
247
  add_this_to_all_ends -= subtract_this_from_ends # now we allow negative :)
224
- #raise if splits.size > 0 # for now
248
+ # raise if splits.size > 0 # just ignore them for now
225
249
  mutes = incoming["mutes"] || {}
226
250
  blanks = incoming["blank_outs"] || {}
227
251
  mutes = mutes.map{|k, v| [k,v,:mute]}
228
252
  blanks = blanks.map{|k, v| [k,v,:blank]}
229
- combined = (mutes+blanks).sort.map{|s,e,type| [translate_string_to_seconds(s), translate_string_to_seconds(e), type]}
253
+ combined = (mutes+blanks).map{|s,e,type| [translate_string_to_seconds(s), translate_string_to_seconds(e), type]}.sort
230
254
 
231
255
  # detect any weirdness...
232
256
  previous = nil
233
- combined.map!{|current|
257
+ combined.map!{ |current|
234
258
  s,e,type = current
235
259
  if e < s || !s || !e || !type
236
- raise SyntaxError.new("detected an end before a start or other weirdness: #{e} < #{s}")
260
+ p caller
261
+ raise SyntaxError.new("detected an end before a start or other weirdness: #{s} > #{e}")
237
262
  end
238
263
  if previous
239
264
  ps, previous_end, pt = previous
240
265
  if (s < previous_end)
241
- raise SyntaxError.new("detected an overlap #{current.join(' ')} #{previous.join(' ')}")
266
+ raise SyntaxError.new("detected an overlap current #{s} < #{previous_end} of current: #{current.join(' ')} previous: #{previous.join(' ')}")
242
267
  end
243
-
244
268
  end
245
269
  previous = current
246
- # do the math later to allow for ones that barely hit into each other 1.0 2.0, 2.0 3.0
247
- [s-subtract_this_from_beginnings, e+add_this_to_all_ends,type]
270
+ # do the math later to allow for ones that barely hit into each other 1.0 2.0, 2.0 3.0
271
+ [s-subtract_this_from_beginnings, e+add_this_to_all_ends,type]
248
272
  }
249
273
  combined
250
274
  end
@@ -88,7 +88,7 @@ module SensibleSwing
88
88
 
89
89
  def initialize start_visible = true, args = ARGV # lodo not optionals
90
90
  super "Sensible-Cinema #{VERSION} (GPL)"
91
- @args = args
91
+ @args = args # save them away so this works with sub-child-windows
92
92
  force_accept_license_first # in other file :P
93
93
  setDefaultCloseOperation JFrame::EXIT_ON_CLOSE # closes the whole app when they hit X ...
94
94
  @panel = JPanel.new
@@ -105,10 +105,15 @@ module SensibleSwing
105
105
  @current_dvds_line2 = add_text_line ""
106
106
  @callbacks_for_dvd_edl_present = []
107
107
  DriveInfo.create_looping_drive_cacher
108
- DriveInfo.add_notify_on_changed_disks { update_currently_inserted_dvd_list }
109
-
110
- setIconImage(ImageIcon.new(__DIR__ + "/../vendor/profs.png").getImage())
108
+ DriveInfo.add_notify_on_changed_disks { update_currently_inserted_dvd_list }
109
+ icon_filename = __DIR__ + "/../../vendor/profs.png"
110
+ raise unless File.exist? icon_filename # it doesn't check this for us?
111
+ setIconImage(ImageIcon.new(icon_filename).getImage())
111
112
  check_for_various_dependencies
113
+ LocalStorage.set_once('init_preferences_once') {
114
+ show_blocking_message_dialog "lets setup some preferences once..."
115
+ set_individual_preferences
116
+ }
112
117
  set_visible start_visible
113
118
  end
114
119
 
@@ -302,7 +307,6 @@ KP_ENTER dvdnav select
302
307
  upconv = ""
303
308
  end
304
309
  if OS.doze?
305
- # we want this even if we don't have -osd-add, since it adds confidence :)
306
310
  mplayer_loc = LocalModifiedMplayer
307
311
  assert File.exist?(mplayer_loc)
308
312
  else
@@ -412,20 +416,25 @@ KP_ENTER dvdnav select
412
416
 
413
417
  nav, mpeg_time = descriptors['dvd_nav_packet_offset'] # like [0.5, 0.734067]
414
418
  if nav
415
- offset_time = mpeg_time*1/1.001 - nav # our reading like 0.5 is actually a bit offset, since in reality that "means 4.997" or what not
419
+ mpeg_time *= 1/1.001 # -> 29.97 fps
420
+ offset_time = mpeg_time - nav
416
421
  else
417
422
  # readings: 0.213 0.173 0.233 0.21 0.18 0.197 they're almost all right around 0.20...
418
- show_blocking_message_dialog "error--your DVD EDL doesn\'t list a start offset time [dvd_nav_packet_offset] which is needed for precise accurate timing. Please run\nadvanced mode -> Display information about current DVD\nand add it to the EDL. Using a default for now..."
423
+ show_blocking_message_dialog "error--your DVD EDL doesn\'t list a start offset time [dvd_nav_packet_offset] which is needed for precise accurate timing. Please run\nadvanced mode -> Display information about current DVD\nand add it to the EDL. Using a default for now...if you tweak any timing info you may want to set this more accurately first!"
419
424
  offset_time = 0.20
420
- p caller
421
425
  end
422
426
  raise if offset_time <= 0 # unexpected...
423
- out << "-osd-add #{ "%0.3f" % offset_time}"
427
+ # -osd-add is because the initial NAV packet is "x" seconds off from the mpeg, and since
428
+ # we have it set within mplayer to "prefer to just give you the MPEG time when you haven't passed a DVD block"
429
+ # we wanted to match that more precisely once we did get past it.
430
+ # so basically today we are trying to "match" the underlying MPEG time well. Which is wrong, of course.
431
+ # either match the file or match the DVD, punk!
432
+ out << "-osd-add #{ "%0.3f" % offset_time}"
424
433
  out.join(' ')
425
434
  end
426
435
 
427
436
  if OS.doze? # avoids spaces in filenames :)
428
- EdlTempFile = EightThree.convert_path_to_8_3(Dir.tmpdir) + '\\mplayer.temp.edl'
437
+ EdlTempFile = EightThree.convert_path_to_8_3(Dir.tmpdir) + '\\mplayer.edl' # stay 8.3 friendly :)
429
438
  else
430
439
  raise if Dir.tmpdir =~ / / # that would be unexpected, and possibly cause problems...
431
440
  EdlTempFile = Dir.tmpdir + '/mplayer.temp.edl'
@@ -477,8 +486,12 @@ KP_ENTER dvdnav select
477
486
 
478
487
  # MplayerBeginingBuffer = 1.0
479
488
  # MplayerEndBuffer = 0.0
489
+ def begin_buffer_preference
490
+ LocalStorage['mplayer_beginning_buffer']
491
+ end
480
492
 
481
- def play_smplayer_edl_non_blocking optional_file_with_edl_path = nil, extra_mplayer_commands_array = [], force_mplayer = false, start_full_screen = true, add_secs_end = 0, add_secs_begin = LocalStorage['mplayer_beginning_buffer'], show_subs = false
493
+ def play_smplayer_edl_non_blocking optional_file_with_edl_path = nil, extra_mplayer_commands_array = [], force_mplayer = false, start_full_screen = true, add_secs_end = 0,
494
+ add_secs_begin = begin_buffer_preference, show_subs = false
482
495
  if we_are_in_create_mode
483
496
  assert(add_secs_begin == 0 && add_secs_end == 0)
484
497
  end
@@ -489,8 +502,19 @@ KP_ENTER dvdnav select
489
502
  drive_or_file, dvd_volume_name, dvd_id, edl_path, descriptors = choose_dvd_or_file_and_edl_for_it
490
503
  end
491
504
  start_add_this_to_all_ts = 0
492
- if edl_path # some don't care...
493
- descriptors = EdlParser.parse_file edl_path
505
+
506
+ if edl_path # some don't have one [?]
507
+ begin
508
+ # TODO combine these 2 methods yipzers
509
+ descriptors = EdlParser.parse_file edl_path
510
+ splits = [] # TODO not pass as parameter either
511
+ edl_contents = MplayerEdl.convert_to_edl descriptors, add_secs_end, add_secs_begin, splits, start_add_this_to_all_ts # add a sec to mutes to accomodate for mplayer's oddness..
512
+ File.write(EdlTempFile, edl_contents)
513
+ extra_mplayer_commands_array << "-edl #{EdlTempFile}"
514
+ rescue SyntaxError => e
515
+ show_blocking_message_dialog "unable to parse file! #{edl_path} #{e}"
516
+ raise
517
+ end
494
518
  title_track = get_title_track_string(descriptors)
495
519
  end
496
520
 
@@ -510,13 +534,6 @@ KP_ENTER dvdnav select
510
534
  end
511
535
  end
512
536
 
513
- if edl_path
514
- splits = [] # TODO not pass as parameter either
515
- edl_contents = MplayerEdl.convert_to_edl descriptors, add_secs_end, add_secs_begin, splits, start_add_this_to_all_ts # add a sec to mutes to accomodate for mplayer's oddness..
516
- File.write(EdlTempFile, edl_contents)
517
- extra_mplayer_commands_array << "-edl #{File.expand_path EdlTempFile}"
518
- end
519
-
520
537
  run_smplayer_non_blocking drive_or_file, title_track, extra_mplayer_commands_array.join(' '), force_mplayer, show_subs, start_full_screen, get_srt_filename(descriptors, edl_path)
521
538
  end
522
539
 
@@ -538,13 +555,13 @@ KP_ENTER dvdnav select
538
555
  end
539
556
 
540
557
  def new_nonexisting_filechooser_and_go title = nil, default_dir = nil, default_file = nil
541
- bring_to_front unless OS.mac? # causes triples on mac!
558
+ bring_to_front unless OS.mac? # causes triples on mac! TODO rdp
542
559
  JFileChooser.new_nonexisting_filechooser_and_go title, default_dir, default_file
543
560
  end
544
561
 
545
562
  # also caches directory previously selected ...
546
563
  def new_existing_file_selector_and_select_file title, dir = nil
547
- bring_to_front unless OS.mac?
564
+ bring_to_front unless OS.mac? # causes duplicate prompts or something?
548
565
  unique_trace = caller.inspect
549
566
  if LocalStorage[unique_trace]
550
567
  dir = LocalStorage[unique_trace]
@@ -557,7 +574,6 @@ KP_ENTER dvdnav select
557
574
  end
558
575
 
559
576
  def show_blocking_message_dialog(message, title = message.split("\n")[0], style= JOptionPane::INFORMATION_MESSAGE)
560
- bring_to_front
561
577
  SwingHelpers.show_blocking_message_dialog message, title, style
562
578
  end
563
579
 
@@ -568,10 +584,9 @@ KP_ENTER dvdnav select
568
584
  SwingHelpers.show_non_blocking_message_dialog message, close_button_text
569
585
  end
570
586
 
571
- include_class javax.swing.UIManager
587
+ java_import javax.swing.UIManager
572
588
 
573
589
  def get_user_input(message, default = '', cancel_ok = false)
574
- bring_to_front
575
590
  SwingHelpers.get_user_input message, default, cancel_ok
576
591
  end
577
592
 
@@ -586,10 +601,9 @@ KP_ENTER dvdnav select
586
601
  end
587
602
 
588
603
  def show_select_buttons_prompt message, names ={}
589
- JOptionPane.show_select_buttons_prompt(message, names)
604
+ SwingHelpers.show_select_buttons_prompt(message, names)
590
605
  end
591
606
 
592
-
593
607
  def parse_edl path
594
608
  EdlParser.parse_file path
595
609
  end
@@ -676,6 +690,50 @@ KP_ENTER dvdnav select
676
690
  a.close
677
691
  end
678
692
 
693
+ def we_are_in_upconvert_mode
694
+ @args.index("--upconvert-mode")
695
+ end
696
+
697
+ def setup_default_buttons
698
+ if we_are_in_upconvert_mode
699
+ add_play_upconvert_buttons
700
+ else
701
+ if we_are_in_create_mode
702
+ setup_create_buttons
703
+ else
704
+ setup_normal_buttons
705
+ end
706
+
707
+ end # big else
708
+
709
+ @exit = new_jbutton("Exit", "Exits the application and kills any background processes that are running at all--don't exit unless you are done processing all the way!")
710
+ @exit.on_clicked {
711
+ Thread.new { self.close } # don't waste the time to close it :P
712
+ puts 'Thank you for using Sensible Cinema. Come again!'
713
+ System.exit 0
714
+ }
715
+
716
+ increment_button_location
717
+ increment_button_location
718
+ self
719
+
720
+ end
721
+
722
+ def get_disk_chooser_window names
723
+ DropDownSelector.new(self, names, "Click to select DVD drive")
724
+ end
725
+
726
+ def get_temp_file_name name_with_ext
727
+ File.dirname(EdlTempFile) + '/' + name_with_ext
728
+ end
729
+
730
+ # converts to full path, 8.3 if on doze
731
+ def normalize_path path
732
+ path = File.expand_path path
733
+ path = EightThree.convert_path_to_8_3 path if OS.doze?
734
+ end
735
+
736
+
679
737
  end
680
738
 
681
739
  end
@@ -3,7 +3,8 @@ module SensibleSwing
3
3
  class MainWindow
4
4
 
5
5
  def add_options_that_use_local_files
6
- check_for_file_manipulation_dependencies
6
+ force_accept_file_style_license
7
+ check_for_file_manipulation_dependencies
7
8
  add_text_line 'These are Create Options that operate on a file:'
8
9
 
9
10
  @preview_section = new_jbutton( "Preview a certain time frame (edited)" )
@@ -41,7 +42,7 @@ module SensibleSwing
41
42
  sleep 0.5 # lodo take out ???
42
43
  background_thread.join if background_thread # let it write out the original fulli, if necessary [?]
43
44
  nice_file = wrote_to_here_fulli
44
- run_smplayer_blocking nice_file, nil, "-edl #{normalize_path EdlTempFile}", false, true, false, nil
45
+ run_smplayer_blocking nice_file, nil, "-edl #{EdlTempFile}", false, true, false, nil
45
46
  }
46
47
  end
47
48
 
@@ -9,9 +9,11 @@ module SensibleSwing
9
9
  }
10
10
  end
11
11
 
12
- def setup_advanced_buttons
13
-
14
- add_text_line 'Normal playback Options:'
12
+ def setup_create_buttons
13
+ # only create mode needs this uh guess
14
+ EdlParser.on_any_file_changed_single_cached_thread { DriveInfo.notify_all_drive_blocks_that_change_has_occured }
15
+
16
+ add_text_line 'Normal playback Options:'
15
17
  new_jbutton("Display Standard Playback Options") do
16
18
  window = new_child_window
17
19
  window.setup_normal_buttons
@@ -45,13 +47,14 @@ module SensibleSwing
45
47
  end
46
48
 
47
49
  add_callback_for_dvd_edl_present { |disk_available, edl_available|
50
+ #TODO rdp file buttons
48
51
  @open_current.set_enabled edl_available
49
- @create_new_edl_for_current_dvd.set_enabled disk_available
52
+ #@create_new_edl_for_current_dvd.set_enabled disk_available
50
53
  if edl_available
51
54
  @create_new_edl_for_current_dvd.text= create_new_edl_for_current_dvd_text + " [yours already has one!]"
52
55
  else
53
56
  if disk_available
54
- @create_new_edl_for_current_dvd.text= create_new_edl_for_current_dvd_text + " [doesn't have one yet!]"
57
+ @create_new_edl_for_current_dvd.text= create_new_edl_for_current_dvd_text + " [it doesn't have one yet!]"
55
58
  else
56
59
  @create_new_edl_for_current_dvd.text= create_new_edl_for_current_dvd_text + " [no disk inserted!]"
57
60
  end
@@ -88,35 +91,41 @@ module SensibleSwing
88
91
  add_to_end = "0.0"#get_user_input("How much time to add to the end of every subtitle entry (ex: (1:00,1:04) becomes (1:00,1:05))", "0.0")
89
92
 
90
93
  if show_select_buttons_prompt("Sometimes subtitle files' time signatures don't match precisely with the video.\nWould you like to enter some information to allow it to synchronize the timestamps?\n (on the final pass you should do this, even if it already matches well, for future information' sake)") == :yes
91
- with_autoclose_message("parsing srt file...") do
94
+ euphemized_synchronized_entries = nil
95
+ with_autoclose_message("parsing srt file... #{srt_filename}") do
92
96
  parsed_profanities, euphemized_synchronized_entries = SubtitleProfanityFinder.edl_output_from_string File.read(srt_filename), {}, 0, 0, 0, 0, 3000, 3000
93
- write_subs_to_file euphemized_filename = EdlTempFile + '.euphemized.srt.txt', euphemized_synchronized_entries
97
+ write_subs_to_file euphemized_filename = get_temp_file_name('euphemized.subtitles.txt'), euphemized_synchronized_entries
94
98
  open_file_to_edit_it euphemized_filename
95
99
  sleep 0.5 # let it open in TextEdit/Notepad first...
96
100
  bring_to_front
97
101
  end
98
102
 
99
103
  if show_select_buttons_prompt("Would you like to start playing the movie in mplayer, to be able to search for subtitle timestamp times [you probably do...]?\n") == :yes
100
- Thread.new { play_dvd_smplayer_unedited true }
101
- show_blocking_message_dialog "ok--use the arrow keys and pgdown/pgup to search/scan, and then '.' to pinpoint a precise subtitle start time within mplayer.\nYou will be prompted for a beginning and starting timestamp time."
104
+ show_blocking_message_dialog "ok--use the arrow keys and pgdown/pgup to search/scan, and then '.' to pinpoint a precise subtitle start time within mplayer.\nYou will be prompted for a beginning and starting timestamp time to search for."
105
+ play_dvd_smplayer_unedited true
102
106
  end
103
- all_entries = SubtitleProfanityFinder.split_to_entries File.read(srt_filename)
107
+ all_entries = euphemized_synchronized_entries
108
+
109
+ all_entries.shift if all_entries[0].text =~ / by |downloaded/i # only place I think
110
+ all_entries.pop if all_entries[-1].text =~ / by |downloaded/i
111
+
104
112
  display_and_raise "unable to parse subtitle file?" unless all_entries.size > 10
105
113
 
106
114
  start_text = all_entries[0].single_line_text
107
115
  start_srt_time = all_entries[0].beginning_time
108
116
  human_start = EdlParser.translate_time_to_human_readable(start_srt_time)
109
- start_movie_ts = get_user_input("Enter beginning timestamp within the movie itself for when the subtitle \"#{start_text}\"\nfirst frame the subtitle appears on the on screen display (possibly near #{human_start})")
117
+ start_movie_ts = get_user_input("Enter beginning timestamp within the movie itself for when the subtitle \"#{start_text}\"\nfirst frame the subtitle appears on the on screen display (possibly near #{human_start})", @start_movie_remember)
118
+ @start_movie_remember = start_movie_ts
110
119
  start_movie_time = EdlParser.translate_string_to_seconds start_movie_ts
111
120
  if(show_select_buttons_prompt 'Would you like to select an ending timestamp at the end or 3/4 mark of the movie [end can be a spoiler at times]?', :yes => 'very end of movie', :no => '3/4 of the way into movie') == :yes
112
121
  end_entry = all_entries[-1]
113
122
  else
114
- end_entry = all_entries[all_entries.length*0.75]
123
+ end_entry = all_entries[all_entries.length*0.75]
115
124
  end
116
125
  end_text = end_entry.single_line_text
117
126
  end_srt_time = end_entry.beginning_time
118
127
  human_end = EdlParser.translate_time_to_human_readable(end_srt_time)
119
- end_movie_ts = get_user_input("Enter beginning timestamp within the movie itself for when the subtitle #{end_entry.index_number}\n\"#{end_text}\"\nfirst appears (possibly near #{human_end}).\nYou can find it by searching to near that time in the movie [pgup+pgdown, then arrow keys], find some subtitle, then find where that subtitle is within the .srt file to see where it lies\nrelative to the one you are interested in\nthen seek relative to that to find the one you want.")
128
+ end_movie_ts = get_user_input("Enter beginning timestamp within the movie itself for when the subtitle ##{end_entry.index_number}\n\"#{end_text}\"\nfirst appears (possibly near #{human_end}).\nYou can find it by searching to near that time in the movie [pgup+pgdown, then arrow keys], find some subtitle, then find where that subtitle is within the .srt file to see where it lies\nrelative to the one you are interested in\nthen seek relative to that to find the one you want.")
120
129
  end_movie_time = EdlParser.translate_string_to_seconds end_movie_ts
121
130
  else
122
131
  start_srt_time = 0
@@ -126,36 +135,38 @@ module SensibleSwing
126
135
  end
127
136
 
128
137
  parsed_profanities, euphemized_synchronized_entries = nil
129
- with_autoclose_message("parsing srt file...") do
138
+ with_autoclose_message("parsing srt file... #{srt_filename}") do
130
139
  parsed_profanities, euphemized_synchronized_entries = SubtitleProfanityFinder.edl_output_from_string File.read(srt_filename), {}, add_to_beginning.to_f, add_to_end.to_f, start_srt_time, start_movie_time, end_srt_time, end_movie_time
131
140
  end
132
141
 
133
- filename = EdlTempFile + '.parsed.txt'
134
- out = "# add these into your \"mute\" section if you deem them mutable\n" + parsed_profanities
135
- if end_srt_time != 3000
136
- out += %!\n\n#Also add these lines at the bottom of the EDL (for later coordination):\n"beginning_subtitle" => ["#{start_text}", "#{start_movie_ts}"],! +
137
- %!\n"ending_subtitle_entry" => ["#{end_text}", "#{end_movie_ts}"],!
138
- middle_entry = euphemized_synchronized_entries[euphemized_synchronized_entries.length*0.5]
139
- show_blocking_message_dialog "You may want to double check if the math worked out.\n\"#{middle_entry.single_line_text}\" (##{middle_entry.index_number})\nshould first appear at #{EdlParser.translate_time_to_human_readable middle_entry.beginning_time}\nIf it's off much you may want to try a different .srt file"
140
- end
142
+ filename = get_temp_file_name('partial.edl.txt')
143
+ out = "# copy and paste these into your \"mute\" section of A SEPARATE EDL already created with the other buttons, for lines you deem them mutable\n" + parsed_profanities
144
+ out += %!\n\n#Also add these lines at the bottom of the EDL (for later coordination):\n"beginning_subtitle" => ["#{start_text}", "#{start_movie_ts}"],! +
145
+ %!\n"ending_subtitle_entry" => ["#{end_text}", "#{end_movie_ts}"],!
146
+ middle_entry = euphemized_synchronized_entries[euphemized_synchronized_entries.length*0.5]
147
+ show_blocking_message_dialog "You may want to double check if the math worked out.\n\"#{middle_entry.single_line_text}\" (##{middle_entry.index_number})\nshould appear at #{EdlParser.translate_time_to_human_readable middle_entry.beginning_time}\nIf it's off much you may want to try a different .srt file"
141
148
  File.write filename, out
142
149
  open_file_to_edit_it filename
143
150
  sleep 1 # let it open
144
151
 
145
- if show_select_buttons_prompt("Would you like to write out a synchronized, euphemized .srt file [useful if you want to watch the movie with sanitized subtitles later]?") == :yes
146
- out_file = new_nonexisting_filechooser_and_go("Select filename to write to", File.dirname(srt_filename), File.basename(srt_filename)[0..-5] + ".euphemized.srt")
147
- write_subs_to_file out_file, euphemized_synchronized_entries
148
- show_in_explorer out_file
149
- end
152
+ if LocalStorage['prompt_obscure_options']
153
+ if show_select_buttons_prompt("Would you like to write out a synchronized, euphemized .srt file [useful if you want to watch the movie with sanitized subtitles later]\nyou probably don't?") == :yes
154
+ out_file = new_nonexisting_filechooser_and_go("Select filename to write to", File.dirname(srt_filename), File.basename(srt_filename)[0..-5] + ".euphemized.srt")
155
+ write_subs_to_file out_file, euphemized_synchronized_entries
156
+ show_in_explorer out_file
157
+ end
158
+ end
150
159
 
151
160
  end
152
161
 
153
162
  add_text_line 'Create: Advanced View Edited Options'
154
163
 
155
- @mplayer_edl_with_subs = new_jbutton( "Watch DVD edited (realtime) (mplayer) (yes subtitles)") do
164
+ @mplayer_edl_with_subs = new_jbutton( "Watch DVD edited (realtime) (with mplayer, subtitles)") do
156
165
  watch_dvd_edited_realtime_mplayer true
157
166
  end
158
167
 
168
+ @mplayer_edl_with_subs.tool_tip="This watches it in mplayer, which has access to its console output, and also includes subtitles."
169
+
159
170
  @mplayer_partial = new_jbutton( "Watch DVD edited (realtime) (mplayer) based on timestamp") do
160
171
  times = get_start_stop_times_strings
161
172
  times.map!{|t| EdlParser.translate_string_to_seconds t}
@@ -164,6 +175,8 @@ module SensibleSwing
164
175
  extra_mplayer_commands = ["-ss #{start_time}", "-endpos #{end_time - start_time}"]
165
176
  play_smplayer_edl_non_blocking nil, extra_mplayer_commands, true, false, add_end = 0.0, add_begin = 0.0 # create mode => aggressive
166
177
  end
178
+
179
+ @mplayer_partial.tool_tip="this can play just a specific portion of your film, like from second 30 to 35, for testing."
167
180
 
168
181
  new_jbutton("Display mplayer keyboard commands/howto/instructions") do
169
182
  show_mplayer_instructions
@@ -189,69 +202,14 @@ module SensibleSwing
189
202
  add_text_line "Less commonly used Edit options:"
190
203
 
191
204
  new_jbutton("Create new Edit List (for netflix instant or movie file)") do # LODO VIDEO_TS here too?
192
- names = ['movie file', 'netflix instant']
193
- dialog = DropDownSelector.new(self, names, "Select type")
194
- type = dialog.go_selected_value
195
- extra_options = {}
196
- if type == 'movie file'
197
- path = SwingHelpers.new_previously_existing_file_selector_and_go "Select file to create EDL for"
198
- guess_name = File.basename(path).split('.')[0..-2].join('.') # like yo.something.720p.HDTV.X264-DIMENSION.m4v maybe?
199
- extra_options['filename'] = File.basename path
200
- require 'lib/movie_hasher'
201
- extra_options['movie_hash'] = MovieHasher.compute_hash path
202
- else
203
- url = get_user_input "Please input the movies url (like http://www.netflix.com/Movie/Curious-George/70042686 )" #?
204
- if url =~ /netflix/
205
- guess_name = url.split('/')[-2]
206
- else
207
- show_blocking_message_dialog "non hulu/netflix? please report!"
208
- type = 'unknown'
209
- guess_name = url.split('/')[-1]
210
- end
211
- extra_options['url'] = url
212
- end
213
- english_name = get_user_input "Enter name of movie", guess_name.gsub(/[-._]/, ' ')
214
- filename = new_nonexisting_filechooser_and_go 'Pick new EDL filename', EdlParser::EDL_DIR + '/..', english_name.gsub(' ', '_') + '.txt'
215
- display_and_raise "needs .txt extension" unless filename =~ /\.txt$/i
216
-
217
- output = <<-EOL
218
- # edl_version_version 1.1, created by sensible cinema v#{VERSION}
219
- # comments can go be created by placing text after a # on any line, for example this one.
220
- "name" => "#{english_name}",
221
-
222
- "source" => "#{type}",
223
- #{extra_options.map{|k, v| %!\n"#{k}" => "#{v}",\n!}}
224
- "mutes" => [
225
- # an example line, uncomment the leading "#" to make it active
226
- # "0:00:01.0", "0:00:02.0", "profanity", "da..",
227
- ],
228
-
229
- "blank_outs" => [
230
- # an example line, uncomment the leading "#" to make it active
231
- # "00:03:00.0" , "00:04:00.0", "violence", "of some sort",
232
- ],
233
-
234
- "timestamps_relative_to" => ["#{type}"],
235
- # "not edited out stuff" => "some...",
236
- # "closing thoughts" => "only ...",
237
- # "subtitles_to_display_relative_path" => "some_file.srt" # if you want to display some custom subtitles alongside your movie
238
- EOL
239
- File.write filename, output
240
- open_file_to_edit_it filename
205
+ create_new_for_file_or_netflix
241
206
  end
242
207
 
243
- new_jbutton("Show even more rarely used buttons") do
208
+ new_jbutton("Show more (rarely used) buttons/options") do
244
209
  child = new_child_window
245
210
  child.show_rarely_used_buttons
246
211
  end
247
212
 
248
- add_text_line 'Options for creating an edited movie file from a local file:'
249
-
250
- new_jbutton("Show options to help with creating a fully edited movie file") do
251
- window = new_child_window
252
- window.add_options_that_use_local_files
253
- end
254
-
255
213
  end
256
214
 
257
215
  def write_subs_to_file out_file, euphemized_synchronized_entries
@@ -277,12 +235,6 @@ module SensibleSwing
277
235
  end
278
236
  end
279
237
 
280
- @open_list = new_jbutton("Open/Edit an arbitrary file (EDL, .srt file, whatever)")
281
- @open_list.on_clicked {
282
- filename = new_existing_file_selector_and_select_file("Pick any file to open in editor", EdlParser::EDL_DIR)
283
- open_file_to_edit_it filename
284
- }
285
-
286
238
  @display_dvd_info = new_jbutton( "Display information about current DVD (ID, timing, etc.)" )
287
239
  @display_dvd_info.tool_tip = "This is useful to setup a DVD's 'unique ID' within an EDL for it. \nIf your EDL doesn't have a line like disk_unique_id => \"...\" then you will want to run this to be able to add that line in."
288
240
  @display_dvd_info.on_clicked {
@@ -290,7 +242,7 @@ module SensibleSwing
290
242
  out_hashes, title_lengths = get_disk_info
291
243
  out_string = out_hashes.map{|name, value| name.inspect + ' => ' + value.inspect + ','}.join("\n") + "\n" + title_lengths.join("\n")
292
244
  out_string += %!\n"timestamps_relative_to" => ["dvd_start_offset","29.97"],! # since they're all this way currently
293
- filename = EdlTempFile + '.disk_info.txt'
245
+ filename = get_temp_file_name('disk_info.txt')
294
246
  File.write filename, out_string
295
247
  open_file_to_edit_it filename
296
248
  out_string # for unit tests :) TODO
@@ -343,9 +295,18 @@ module SensibleSwing
343
295
  version (which includes an updated version of mplayer that fixes some bugs in EDL playback)
344
296
  EOL
345
297
  @create_dot_edl.on_clicked {
346
- show_blocking_message_dialog "Warning: With XBMC you'll need Eden 11.0 for mutes to work"
298
+ show_blocking_message_dialog "Warning: With XBMC you'll need at least Eden v11.0 for mutes to work at all"
347
299
  choose_file_and_edl_and_create_sxs_or_play true
348
300
  }
301
+
302
+ add_text_line 'Options for creating an edited movie file from a local file:'
303
+
304
+ new_jbutton("Show options to help with creating a fully edited movie file") do
305
+ window = new_child_window
306
+ window.add_options_that_use_local_files
307
+ end
308
+
309
+
349
310
  if LocalStorage['have_zoom_button']
350
311
  @create_zoomplayer = new_jbutton( "Create a ZoomPlayer MAX compatible EDL file") do
351
312
  raise unless OS.doze?
@@ -391,6 +352,9 @@ module SensibleSwing
391
352
  title_lengths = title_lengths_output.split("\n").select{|line| line =~ /TITLE.*LENGTH/}
392
353
  # ID_DVD_TITLE_4_LENGTH=365.000
393
354
  titles_with_length = title_lengths.map{|name| name =~ /ID_DVD_TITLE_(\d+)_LENGTH=([\d\.]+)/; [$1, $2.to_f]}
355
+ if titles_with_length.length > 50
356
+ show_blocking_message_dialog "this DVD has > 50 titles, this may mean that our 'guess' for the main title will be off, please double check the right number\nby starting the main movie in VLC then Playback menu -> title to see which number it is on."
357
+ end
394
358
  largest_title = titles_with_length.max_by{|title, length| length}
395
359
  if !largest_title
396
360
  display_and_raise "unable to parse title lengths? maybe need to clean disk first? #{title_lengths_output}"
@@ -408,7 +372,7 @@ module SensibleSwing
408
372
 
409
373
  def watch_dvd_edited_realtime_mplayer show_subs
410
374
  edl_out_command = ""
411
- if !@has_ever_rejected_edl_outfile
375
+ if LocalStorage['prompt_obscure_options']
412
376
  answer = show_select_buttons_prompt <<-EOL, {}
413
377
  Would you like to create an .edl outfile as it plays (hit button to capture timestamps)?
414
378
  EOL
@@ -452,11 +416,11 @@ module SensibleSwing
452
416
  mpeg = $2.to_f
453
417
  if !outs[:dvd_nav_packet_offset] && nav > 0.0 # like 0.4
454
418
  if mpeg < nav
455
- # case there is an MPEG split before the second NAV packet [ratatouille]
419
+ # case there is an MPEG split before the second NAV packet [ratatouille, hp]
456
420
  p mpeg, nav, old_mpeg
457
421
  assert old_mpeg > 0.3
458
422
  mpeg = old_mpeg + mpeg - 0.033367 # assume 30 fps, and that this is the second frame since it occurred, since the first one we apparently display "weird suddenly we're not a dvd?"
459
- show_blocking_message_dialog "this dvd has some weird stuff at the start, attempting to accomodate..."
423
+ show_blocking_message_dialog "this dvd has some weird timing stuff at the start, attempting to accomodate...please report..."
460
424
  end
461
425
  outs[:dvd_nav_packet_offset] = [nav, mpeg] # like [0.4, 0.6] or the like
462
426
  else
@@ -464,7 +428,7 @@ module SensibleSwing
464
428
  end
465
429
  end
466
430
  }
467
- show_blocking_message_dialog "unable to calculate time?" unless outs.length == 2
431
+ show_blocking_message_dialog "unable to calculate DVD start time from #{command}?" unless outs.length == 2
468
432
  outs
469
433
  end
470
434
 
@@ -537,12 +501,12 @@ module SensibleSwing
537
501
  filename = EdlParser::EDL_DIR + "/edls_being_edited/" + english_name.gsub(' ', '_') + '.txt'
538
502
  filename.downcase!
539
503
  if File.exist?(filename)
540
- show_blocking_message_dialog 'cannot overwrite file in the edit dir that already has same name, opening it instead...'
541
- else
542
- File.write(filename, input)
504
+ show_blocking_message_dialog 'don\'t want to overwrite a file in the edit dir that already has same name, opening it instead...'
505
+ else
506
+ File.write(filename, input)
543
507
  end
544
508
  open_file_to_edit_it filename
545
- end
509
+ end
546
510
 
547
511
  def show_mplayer_instructions
548
512
  show_non_blocking_message_dialog <<-EOL
@@ -560,6 +524,59 @@ module SensibleSwing
560
524
  [ and ] make playback faster or slower [like 2x]
561
525
  EOL
562
526
  end
527
+
528
+ def create_new_for_file_or_netflix
529
+ names = ['movie file', 'netflix instant']
530
+ dialog = DropDownSelector.new(self, names, "Select type")
531
+ type = dialog.go_selected_value
532
+ extra_options = {}
533
+ if type == 'movie file'
534
+ path = SwingHelpers.new_previously_existing_file_selector_and_go "Select file to create EDL for"
535
+ guess_name = File.basename(path).split('.')[0..-2].join('.') # like yo.something.720p.HDTV.X264-DIMENSION.m4v maybe?
536
+ extra_options['filename'] = File.basename path
537
+ require 'lib/movie_hasher'
538
+ extra_options['movie_hash'] = MovieHasher.compute_hash path
539
+ else
540
+ url = get_user_input "Please input the movies url (like http://www.netflix.com/Movie/Curious-George/70042686 )" #?
541
+ if url =~ /netflix/
542
+ guess_name = url.split('/')[-2]
543
+ else
544
+ show_blocking_message_dialog "non hulu/netflix? please report!"
545
+ type = 'unknown'
546
+ guess_name = url.split('/')[-1]
547
+ end
548
+ extra_options['url'] = url
549
+ end
550
+ english_name = get_user_input "Enter name of movie", guess_name.gsub(/[-._]/, ' ')
551
+ filename = new_nonexisting_filechooser_and_go 'Pick new EDL filename', EdlParser::EDL_DIR + '/..', english_name.gsub(' ', '_') + '.txt'
552
+ display_and_raise "needs .txt extension" unless filename =~ /\.txt$/i
553
+
554
+ output = <<-EOL
555
+ # edl_version_version 1.1, created by sensible cinema v#{VERSION}
556
+ # comments can go be created by placing text after a # on any line, for example this one.
557
+ "name" => "#{english_name}",
558
+
559
+ "source" => "#{type}",
560
+ #{extra_options.map{|k, v| %!\n"#{k}" => "#{v}",\n!}}
561
+ "mutes" => [
562
+ # an example line, uncomment the leading "#" to make it active
563
+ # "0:00:01.0", "0:00:02.0", "profanity", "da..",
564
+ ],
565
+
566
+ "blank_outs" => [
567
+ # an example line, uncomment the leading "#" to make it active
568
+ # "00:03:00.0" , "00:04:00.0", "violence", "of some sort",
569
+ ],
570
+
571
+ "timestamps_relative_to" => ["#{type}"],
572
+ # "not edited out stuff" => "some...",
573
+ # "closing thoughts" => "only ...",
574
+ # "subtitles_to_display_relative_path" => "some_file.srt" # if you want to display some custom subtitles alongside your movie
575
+ EOL
576
+ File.write filename, output
577
+ open_file_to_edit_it filename
578
+
579
+ end
563
580
 
564
581
  end
565
582
  end