sensible-cinema 0.23.6 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/LICENSE.TXT +1 -1
  2. data/README +8 -6
  3. data/Rakefile +1 -1
  4. data/TODO +62 -41
  5. data/VERSION +1 -1
  6. data/bin/sensible-cinema +395 -278
  7. data/bin/sensible-cinema-cli +1 -1
  8. data/change_log_with_feature_list.txt +16 -0
  9. data/developer_how_to_contribute_to_the_project.txt +1 -1
  10. data/documentation/{README.TXT → DOCUMENTATION_README.TXT} +0 -0
  11. data/documentation/how_to_create_your_own_delete_lists.txt +7 -7
  12. data/experimental_online_player_ocr_readme.txt +2 -2
  13. data/lib/check_installed_mac.rb +16 -4
  14. data/lib/drive_info.rb +2 -2
  15. data/lib/edl_parser.rb +13 -9
  16. data/lib/mencoder_wrapper.rb +18 -9
  17. data/lib/mplayer_edl.rb +4 -1
  18. data/lib/shutdown_kill.rb +32 -0
  19. data/lib/subtitle_profanity_finder.rb +13 -5
  20. data/lib/swing_helpers.rb +4 -0
  21. data/spec/notes +331 -8
  22. data/spec/sensible_cinema_gui.spec.rb +34 -22
  23. data/template_bats/{advanced--create or edit sensible cinema delete list files.bat → advanced--create or edit sensible cinema edit list files.bat} +0 -0
  24. data/todo.upconvert +13 -0
  25. data/upconvert.bat +2 -0
  26. data/www/index.html +11 -9
  27. data/zamples/edit_decision_lists/dvds/{zz_example_delete_list_that_has_no_cuts_in_it.txt → aa_example_delete_list_that_has_no_cuts_in_it.txt} +0 -0
  28. data/zamples/edit_decision_lists/dvds/{bambi.txt → edls_being_edited/bambi.txt} +0 -0
  29. data/zamples/edit_decision_lists/dvds/{edl_for_unit_tests.txt → edls_being_edited/edl_for_unit_tests.txt} +0 -0
  30. data/zamples/edit_decision_lists/dvds/edls_being_edited/iq.txt +32 -0
  31. data/zamples/edit_decision_lists/dvds/edls_being_edited/other_side_of_heaven.txt +19 -0
  32. data/zamples/edit_decision_lists/dvds/edls_being_edited/snow_white_and_the_7_dwarfs_1937.txt +19 -0
  33. data/zamples/edit_decision_lists/dvds/{potter_prisoner_of_azkaban.txt → harry_potter_prisoner_of_azkaban.txt} +0 -0
  34. data/zamples/edit_decision_lists/{dvds/old_and_inaccurate → old_not_yet_updated/dvds}/White Christmas.txt +0 -0
  35. data/zamples/edit_decision_lists/{dvds/old_and_inaccurate → old_not_yet_updated/dvds}/all_dogs_go_to_heaven.txt +0 -0
  36. data/zamples/edit_decision_lists/{dvds/old_and_inaccurate → old_not_yet_updated/dvds}/cars_disney.txt +1 -1
  37. data/zamples/edit_decision_lists/{dvds/old_and_inaccurate → old_not_yet_updated/dvds}/happy_feet.txt +0 -0
  38. data/zamples/edit_decision_lists/{dvds/old_and_inaccurate → old_not_yet_updated/dvds}/labyrinth.txt +0 -0
  39. data/zamples/edit_decision_lists/{dvds/old_and_inaccurate → old_not_yet_updated/dvds}/making marriage work.txt +0 -0
  40. data/zamples/edit_decision_lists/{dvds/old_and_inaccurate → old_not_yet_updated/dvds}/star_trek_generations_hulu.txt +0 -0
  41. metadata +21 -16
  42. data/zamples/edit_decision_lists/category descriptions.txt +0 -35
data/LICENSE.TXT CHANGED
@@ -2,7 +2,7 @@ All files (c) Roger Pack 2010-2011
2
2
 
3
3
  All files released under the GPLv3 license [1] unless otherwise specified. Ping me if you want/need this changed at some point.
4
4
 
5
- EDL (delete list/edit list) files are released under the Creative Commons License, however.
5
+ EDL (delete list/edit list/EDL) files are released under the Creative Commons License, however.
6
6
 
7
7
  Note: may call out to some 3rd party libraries/executables under their own (separate, open source) licenses and distributions, but they are contained
8
8
  within this package for convenience.
data/README CHANGED
@@ -1,4 +1,4 @@
1
- Sensible-cinema [5] allows you to apply pre-programmed delete lists
1
+ Sensible-cinema [5] allows you to apply pre-programmed edit lists
2
2
  (e.g. Edit Decision Lists [2]) to DVD's you own.
3
3
  I.e. you can edit a DVD to "mute out" or skip certain scenes.
4
4
  This allows you to sit back and relax as you watch a more "sensiblized" showing of your DVD.
@@ -41,14 +41,14 @@ Enjoy your movies!
41
41
  [2] http://en.wikipedia.org/wiki/Edit_decision_list
42
42
  [3] mostly GPL programs, see http://www.gnu.org/licenses/ VLC Media Player, Mplayer/mencoder, ffmpeg, et al.
43
43
  [4] http://lds.org/library/display/0,4945,161-1-11-1,00.html search for the word "wholesome"
44
- [5] Also known to us as "paranoid cinema" (our inside joke :).
44
+ [5] Also known to us as "paranoid cinema" (just an joke :).
45
45
 
46
46
  == Installation ==
47
47
 
48
48
  Installation and usage instructions available here: http://rogerdpack.t28.net/sensible-cinema
49
49
  NB that you want to download it sourceforge, not from github downloads.
50
50
 
51
- == Creating Your Own Delete Lists, or modifying previously existing ones ==
51
+ == Creating Your Own Edit Lists, or modifying previously existing ones ==
52
52
 
53
53
  See the accompanying documentation/how_to_create_your_own_delete_lists.txt file.
54
54
 
@@ -78,7 +78,7 @@ A. Give them the original unedited DVD and a link to sensible-cinema's website.
78
78
 
79
79
  == Caveats ==
80
80
 
81
- NB that "someone" has to first create a delete list, per DVD.
81
+ NB that "someone" has to first create a edit list, per DVD.
82
82
  If one doesn't yet exist for the DVD you want edited,
83
83
  you could create it yourself, or employ somebody to create it. Make sure to submit it
84
84
  back to us when you're done, so that the rest of the users can benefit from it.
@@ -86,7 +86,7 @@ Fortunately just one person has to do it, once, for everybody to benefit, and th
86
86
  editing process is not too bad.
87
87
 
88
88
  We also have a subtitle parser which really helps locate profanity more conveniently, so that will help you
89
- build your delete list.
89
+ build your edit list.
90
90
 
91
91
  Also note that if your DVD has scratches that cause it to skip, the time signatures will be off,
92
92
  so we recommend to always clean your discs first!
@@ -131,6 +131,8 @@ content during the intro) because...they want to get to the movie faster.
131
131
  Or skip commercials in some personal DVD recording.
132
132
  Or use it on their home dvd's. Clearplay does not allow for any of these.
133
133
  Also clearplay doesn't seem to users for example leave comments on their filters, to improve them, etc.
134
+ Also you can't tell from clearplay's list whether a DVD is absent because it's clean, or because they
135
+ haven't done a filter for it.
134
136
 
135
137
  So overall I wanted to build my own that overcame some of these hurdles.
136
138
 
@@ -196,7 +198,7 @@ No really.
196
198
 
197
199
  Note that competition/use of files from sensible cinema is welcome!
198
200
 
199
- In fact, the current end goal is to publish the delete lists (EDL's) to a separate repository with its
201
+ In fact, the current end goal is to publish the edit lists (EDL's) to a separate repository with its
200
202
  own API under the CC license, meaning that even "for profit" users can use them for whatever other use they want, hopefully
201
203
  good uses :) More direct direct competitors are also welcome here. I only made this because I had to
202
204
  and nothing like it existed, so if something else springs up, I'm actually happy to use it instead, too.
data/Rakefile CHANGED
@@ -101,7 +101,7 @@ task 'create_distro_dir' => :gemspec do # depends on gemspec...
101
101
  FileUtils.mkdir_p dir_out
102
102
  FileUtils.cp_r(existing, dir_out) # copies files, subdirs in
103
103
  # these belong in the parent dir, by themselves.
104
- FileUtils.cp(Dir["#{dir_out}/template_bats/*"], "#{dir_out}/..")
104
+ FileUtils.cp(Dir["#{dir_out}/template_bats/*.bat"], "#{dir_out}/..")
105
105
  p 'created (still need to zip it) ' + dir_out
106
106
  FileUtils.rm_rf Dir[dir_out + '/**/{spec}'] # don't need to distribute those..save 3M!
107
107
  end
data/TODO CHANGED
@@ -1,17 +1,17 @@
1
1
  == roadmap [for just tasks, see below though] ==
2
2
 
3
- release: cheap inventionzy, and medium inventionzy
3
+ release: cheap/mediumcheap inventionzy
4
4
  release: C EDL
5
5
  compare netflix/blu-ray timings et al
6
6
 
7
7
  === loose ordering/eventually ===
8
8
  linearize [?] hmm...
9
- re-update todo/all docu/user feedbacks
9
+ re-update todo/all docu/user feedback etc.
10
10
  create web site/api-ify
11
11
  LLC
12
12
  if...back off to just the ffmpeg (plus an "[A,B]" viewer) only...but for now stick with just DVD playback [?] until people want more...
13
13
  no propaganda...
14
- no auto subtitles...
14
+ no auto subtitle downloads...
15
15
  fix VLC dvdnav itself +- mplayer DVD EDL
16
16
 
17
17
  == high prio like blocking bugs ==
@@ -25,14 +25,19 @@
25
25
  url -> url inference [hopefully this is cake...]
26
26
  fix the failing 9 digit test the fancy shmancy way :P
27
27
  can pass in a profanity command line
28
- can handle dual dvdid's
28
+ can handle multiple dvdid's et al
29
29
  youtube: use the javascript API somehow, like http://universalsubtitles.org/en does
30
30
  phase 1: does they use inferred timestamp? can I use that generally, too? [do phase 1--publish simple javascript demo of it muting for awhile after startup]
31
31
  just in case youtube takes over the world
32
32
 
33
- == yes do ordered in conjunction with the above ==
34
- can I just use ffmpeg for -> ts ? http://eotmsnotes.wordpress.com/2011/04/25/tsmuxer-notes/
35
- try buy delete lists from all x,y,z [?] maybe ask for them for free first? ()
33
+ == yes do ordered in conjunction with the above probably ==
34
+ subtitles 2 phase
35
+ unit tests
36
+ add a "scan for expected title, times" (basically all titles, times...)
37
+ complain if times are wrong...
38
+ complain [accomodate option] if start time off...
39
+ lightning strike from various outlets...
40
+ try buy edit lists from all x,y,z [?] maybe ask for them for free first? ()
36
41
  http://www.familysafemovies.com
37
42
  cleanflix (earl? that guy [John webster http://www.amazon.com/Make-Edited-Movies-ebook/dp/B004EYT3BU]?)
38
43
  cougar video (that looks tough...)
@@ -46,38 +51,46 @@
46
51
  family flix
47
52
  http://theeditedmovieencyclopedia.blogspot.com/2008/08/clean-play-dvds-grand-opening-e-mail.html has grande list
48
53
  movie mask wayback machine
49
- next timing thing (notes file)
50
- add the "create .edl file for xbmc/smplayer" button
51
54
 
52
55
  == yes do, un-ordered currently, from the various future release options ==
53
- mplayerx work?
54
- if not, patch that fella...and tell them to fix it!
55
- can accept straight ".edl" files too, as my input
56
+ upconvert better options
57
+ SRT doubles up first IQ
58
+ don't cache selections if they choose a local file...hmm...
59
+ "save to" -> same dir as "get from" yeah
60
+ @instructions "this is great for comparing srt's, except...then you have to..."
61
+ test with cars-ws, mac (to make sure volume name doesn't have spaces)
62
+ can I just use ffmpeg for an initial -> ts ? http://eotmsnotes.wordpress.com/2011/04/25/tsmuxer-notes/
63
+ volume_name => dvd_volume_name
64
+ make it load faster! this is cuh-razy! or splash screen! yes!
65
+ why is the Sintel's EDL seemingly off?
66
+ ascertain how accurate mplayer EDL is...I guess compared to...umm...something?
67
+ fix discrepancy between EDL mplayer and ffmpeg...maybe a new button "accurate EDL playback"?
68
+ maybe search at end of movies for certain things?
69
+ double check--are my ffmpeg splits really really really the same as mplayer's EDL DVD splits? really?
70
+ check with WME plugins, add instructions, then note in the README "support for x..."
56
71
  decide if I want to just use edl's or my fancy-shmancy, or maybe my fancy-shmancy to wrap EDL's?
57
- don't use eval!
72
+ don't have to use eval!
73
+ EDL with JSON on top, full timestamps.
74
+ setpriority for several :)
58
75
  bring to top after a conversion, and for prompts...we get hidden!
59
- ascertain how accurate mplayer EDL is...I guess compared to...umm...something?
60
- fix discrepancy between EDL mplayer and ffmpeg...maybe a new button "accurate EDL playback"?
61
- can auto-use tsmuxer at all
62
- add buttons for "convert 4945 to x" and vice versa...
63
- warn/redirect if wrong looking file extension...
64
- mac just die with instructions to use tsmuxer first...
65
- add a "watch edited from local file" option...
66
- check if some other buttons are outdated...
67
- unit tests (all)
68
- double check--are my ffmpeg splits really really really the same as mplayer's EDL DVD splits? really?
69
- can I avoid requiring use of tsmuxer first?
76
+ can auto-use tsmuxer at all [?]
77
+ mac just die with instructions to use tsmuxer first...
78
+ check if some other buttons are outdated...
79
+ unit tests (all pass)
80
+ auto-copy to clipboard...should be cake, right?
81
+ can I avoid requiring use of tsmuxer first? hmm...
70
82
  check with blu-ray...do they match timing-wise? sub-title wise?
71
83
  donate tsmuxer, makemkv, http://ffmpeg.zeranoe.com/builds, mulder [?] smplayer menumeter
72
- add an mencoder convert with mplayer_breaks button :P
73
- can I just use mencoder -hr-edl-seek (off mpeg) to avoid the fulli phase? please? does it work super-accurately, though, off fulli? off other?
74
- maybe just under an "advanced" window...
75
84
  youtube/hulu timings
85
+ @mplayer do you want a demo disk of how it fails edl dvdnav?
76
86
  split LLC's website+consumer
77
87
  get LLC before a "real" domain name
78
- always don't use auto file hashes to discourage piracy
79
88
  upconverter
89
+ check gl mac
90
+ check permutations
91
+ easier use/"options" setting buttons, remove that one button...
80
92
  employee instructions: watch @ realtime after profanity filter first pass :P
93
+ @makemkv: timing feels broken weird-like!
81
94
  clear runnings
82
95
  have ben and chris test it out, have it work, then ask about video quality
83
96
  me try
@@ -97,30 +110,26 @@
97
110
  can come out of full screen more easily :P
98
111
  note pay for XP http://windows.microsoft.com/en-US/windows/downloads/windows-media-player/plug-ins search for the cheapest
99
112
  note to them windows vista/7: use ac3filter [?]
100
- donate menumeter $
101
- reate the "play previously created edited file for current DVD" button
113
+ [A,B] [?]
114
+ create the "play previously created edited file for current DVD" button
102
115
  note better to previewer "you are about to preview these specific edits..." ?
103
116
  ask for more beta testers for use, ask for more beta testers for creation, too
104
117
  beta release: rinse and repeat with various ppl
105
- youtube videos -> new account name
106
118
  create a semi-accurate phantom edit EDL
107
119
  http://www.chefelf.com/forums/index.php?showtopic=6176
108
120
  karlie?
109
121
  inventionzy: blu-ray OCR
110
122
  port to mac OS X--try everything out (all buttons), make sure all works...
111
- appears that, for now, have to just use mplayer dvd://
112
123
  ppc dvdid?
113
- app store mplayer perhaps?
114
124
  bundle a copy of smplayer locally?
115
- can use a working copy of tsmuxer with instructions :)
116
- typically delete unedited.fulli file automatically
117
- except if it's a specific scene run test...
125
+ instructions for how to use mac ts muxer
118
126
  the final "edited.avi" really "could/should" be playable in WMP...if possible
119
- generic/consumer EDL run through should be through smplayer...do I need/want straight mplayer option too though?
120
127
  do I need tsmuxer?
128
+ "guess" the best title...
121
129
 
122
130
  == other lists ==
123
131
 
132
+ todo.upconvert
124
133
  todo.propaganda
125
134
  todo.inventionzy
126
135
  open_edl_list_org_todo.txt file
@@ -155,6 +164,22 @@
155
164
  investigate dvdrsbvdl (windows media center edl plugin)
156
165
 
157
166
  == DVD+-DVD-realtime backlog (totally unordered, some very low prio, basically all never do) ==
167
+ @mplayer: dvdnav:///e: should play the *menu* please? please?
168
+ @mplayer: do I need -zoom ?
169
+ @smplayer: you don't capture stderr [?] ex -vf scale:1280.0
170
+ @mplayer: http://www.infognition.com/VideoEnhancer/ can I do that through any means LOL?
171
+ @mplayer: gl shucks on windows 7!
172
+ can accept straight ".edl" files too, as my input (?)
173
+ @mplayer: after hitting split DVD sectors, the OSD fraction goes bonkers.
174
+ @mplayer: dump core needs a better message..could use one http://lists.mplayerhq.hu/pipermail/mplayer-users/2007-February/065420.html
175
+ @mplayer: -edl nonexist should warn [?] also when it hits an EDL sector ouput something plz?
176
+ @mplayer: allow EDL to have full timestamps for ease of editing :)
177
+ youtube videos -> new account name
178
+ add an mencoder convert with mplayer_breaks button :P
179
+ can I just use mencoder -hr-edl-seek (off mpeg) to avoid the fulli phase? please? does it work super-accurately, though, off fulli? off other?
180
+ maybe just under an "advanced" window...
181
+ @mplayer homepage: list mulder's not smplayer's, plz?
182
+ also smplayer advertise more prominently :P
158
183
  make this thing load faster: don't require rubygems...uh...faster_require?
159
184
  does xbmc need a "convert to 30fps edl" for DVD?
160
185
  @xbmc can you call out to another player prog plz?
@@ -210,7 +235,6 @@
210
235
  research the gplv3, add terms. Maybe want real lawyer, even?
211
236
  note "others are released under this license, that license"
212
237
  note/include jruby license, include gplv1 et al, note "also included locally"
213
- check if md5 same mac versus PC for VLC/mplayer rips, VLC done several times/fix too
214
238
  disallow choosing empty drive? fail more gracefully when they do?
215
239
  sons of provo "music video" EDL
216
240
  it can "slow certain sections down" that might look way cool! LOL
@@ -276,8 +300,6 @@
276
300
  add button start EDL playback from dvd here [?] (for create mode)
277
301
  re-play as EDL button for both modes--describe on the how to better
278
302
  fix prio for first ffmpeg instance not being settable [huh?]
279
- calculating md5...do this for each disc while they choose it [low prio] :)
280
- if the dll fella is too slow, that is, like my current one is :P
281
303
  check if a newer version of smplayer (+- forum links) can replace raw usage of mplayer now?
282
304
  integrate sub-titles-zy-er auto-download
283
305
  I could integrate discid => hashes => opensubtitles.org
@@ -300,7 +322,6 @@
300
322
  .exe installer
301
323
  just unzips, runs the .bat file for them [?] :)
302
324
  full msi
303
- add md5 "warning" when something (anything) had failed disc fails doesn't match because of DVD read failure...
304
325
  LLC before I ever pay anyone anything, if I ever do
305
326
  add some or any of the following "play now" options...without a true navigator of course :)
306
327
  "round conservatively, yes write inaccurate file straight from DVD in pieces" ?
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.23.6
1
+ 0.24.0
data/bin/sensible-cinema CHANGED
@@ -79,86 +79,156 @@ module SensibleSwing
79
79
  end
80
80
 
81
81
  # currently advanced mode only *adds* buttons
82
- def new_jbutton title, only_on_create_mode, tooltip = nil
82
+ def new_jbutton title, tooltip = nil
83
83
  button = JButton.new title
84
84
  button.tool_tip = tooltip
85
85
  button.set_bounds(44, @starting_button_y, @button_width, 23)
86
- add = true
87
- if we_are_in_create_mode
88
- add = true
89
- else
90
- add = false if only_on_create_mode
91
- end
92
-
93
- if add
94
- increment_button_location
95
- @panel.add button
96
- @buttons << button
86
+ @panel.add button
87
+ @buttons << button
88
+ if block_given? # allow for new_jbutton("xx") do ... end [this works through some miraculous means LOL]
89
+ button.on_clicked { yield }
97
90
  end
91
+ increment_button_location
98
92
  button
99
93
  end
100
94
 
101
95
  def add_text_line line
102
- return unless we_are_in_create_mode
103
96
  jlabel = JLabel.new line
104
97
  happy = Font.new("Tahoma", Font::PLAIN, 11)
105
98
  jlabel.setFont(happy)
106
99
  jlabel.set_bounds(44,@starting_button_y ,460,14)
107
100
  @panel.add jlabel
108
101
  increment_button_location 18
102
+ jlabel
109
103
  end
110
104
 
111
105
  def increment_button_location how_much = 30
112
106
  @starting_button_y += how_much
107
+ setSize @button_width+80, @starting_button_y + 50
113
108
  end
114
109
 
115
110
  def force_accept_license_first
116
- require_blocking_license_accept_dialog 'Sensible Cinema', 'gplv3', 'http://www.gnu.org/licenses/gpl.html', 'Sensible Cinema license agreement',
111
+ require_blocking_license_accept_dialog 'Sensible Cinema', 'gplv3', 'http://www.gnu.org/licenses/gpl.html', 'Sensible Cinema license agreement',
117
112
  "Sensible Cinema is distributed under the gplv3 (http://www.gnu.org/licenses/gpl.html).\nBY CLICKING \"accept\" YOU SIGNIFY THAT YOU HAVE READ, UNDERSTOOD AND AGREED TO ABIDE BY THE TERMS OF THIS AGREEMENT"
118
- require_blocking_license_accept_dialog 'Sensible Cinema', 'is_it_legal_to_copy_dvds.txt file', File.expand_path(File.dirname(__FILE__) + "/../documentation/is_it_legal_to_copy_dvds.txt"),
113
+ require_blocking_license_accept_dialog 'Sensible Cinema', 'is_it_legal_to_copy_dvds.txt file', File.expand_path(File.dirname(__FILE__) + "/../documentation/is_it_legal_to_copy_dvds.txt"),
119
114
  'is_it_legal_to_copy_dvds.txt file', 'I acknowledge that I have read, understand, accept and agree to abide by the implications noted in the documentation/is_it_legal_to_copy_dvds.txt file'
120
- Storage['main_license_accepted'] = VERSION
115
+ Storage['main_license_accepted'] = VERSION
121
116
  end
122
117
 
123
118
  Storage = Storage.new("sensible_cinema_storage")
124
119
 
120
+ def setup_upconvert_buttons
125
121
 
126
- def setup_advanced_buttons
122
+ @watch_file_upconvert = new_jbutton( "Watch a file upconverted (unedited)") do
123
+ # ?? drive, volume, dvd_id = choose_dvd_drive_or_file true
124
+ filename_mpg = new_existing_file_selector_and_select_file( "pick moviefile (like moviename.mpg)")
125
+ play_mplayer_edl [filename_mpg, nil]
126
+ end
127
127
 
128
- add_text_line 'Realtime create Options:'
128
+ @watch_file_upconvert = new_jbutton( "Watch a DVD upconverted (unedited)") do
129
+ # this way wurx...
130
+ #drive, volume, dvd_id = choose_dvd_drive_or_file false # will choose a DVD if mounted...
131
+ #run_smplayer_blocking "dvdnav:///#{drive}", "-nocache" # TODO dvdnav://1-60 is summarily ignored...sniff...
132
+ # LODO mplayer dvdnav:///e: seems really really hosed LOL, and also dvdnav input what the...
133
+ # plush crash smplayer "normal" selecting IQ Menu (ok snow white tho...odd...)
134
+ play_dvd_smplayer_unedited
135
+ end
136
+
137
+ add_set_upconvert_options_button
138
+
139
+ end
140
+
141
+ def add_set_upconvert_options_button
142
+ @show_upconvert_options = new_jbutton( "Change upconvert options (started as #{Storage[UpConvertEnglish] || 'not set'})" ) do
143
+ setup_upconvert_options
144
+ end
145
+
146
+ end
129
147
 
130
- @create_dot_edl = new_jbutton( "Create a moviefilename.edl file", true)
131
- @create_dot_edl.tool_tip = <<-EOL
132
- Create a moviefilename.edl file (corresponding to moviefilename.some_ext which already exists)
133
- XBMC/smplayer (smplayer can be used by WMC plugins, etc.) "automagically detect",
134
- if it exists, and automatically use it .edl to show that file edited played back.
135
- EOL
136
- @create_dot_edl.on_clicked {
137
- filename_mpg = new_existing_file_selector_and_select_file( "pick moviefile (like abc.mpg)")
138
- assert_ownership_dialog
139
- edl_filename = new_existing_file_selector_and_select_file( "Pick EDL file", EDL_DIR)
140
- descriptors = EdlParser.parse_file edl_filename
141
- # LODO these timings...DRY up...plus is XBMC the same? what about on a slower computer?
142
- edl_contents = MplayerEdl.convert_to_edl descriptors, add_secs_end = 0.0, add_secs_beginning = 0.5, splits = []
143
- output_file = filename_mpg.gsub(/\.[^\.]+$/, '') + '.edl'
144
- File.write(output_file, edl_contents)
145
- raise unless File.exist?(output_file)
146
- show_blocking_message_dialog("created #{output_file}")
148
+ UpConvertKey = 'upconvert_setting'
149
+ UpConvertKeyExtra = 'upconvert_setting_extra'
150
+ UpConvertEnglish = 'upconvert_english_name'
151
+
152
+ def setup_upconvert_options
153
+ none = new_jbutton("reset upconvert options to default (none)")
154
+ none.tool_tip = "Having no upconvert options is reasonably good, uses directx for scaling, nice for slow cpu's"
155
+ p 'upconvert options started as:', Storage[UpConvertKey]
156
+ none.on_clicked {
157
+ Storage[UpConvertKey] = nil
158
+ Storage[UpConvertKeyExtra] = nil
159
+ Storage[UpConvertEnglish] = nil
160
+ }
161
+ medium_dvd = new_jbutton("set upconvert options to DVD-style input (high-quality input)") {
162
+ Storage[UpConvertKey] = "hqdn3d=2:1.5:3,scale=SCREEN_X:-1:0:0:3"
163
+ Storage[UpConvertKeyExtra] = "-sws 9 -ssf ls=75.0 -ssf cs=50.0"
164
+ Storage[UpConvertEnglish] = "DVD/HQ"
165
+ display_current_upconvert_setting
147
166
  }
167
+ high_compression = new_jbutton("set upconvert options for playing back highly compressed video") {
168
+ # -autoq 6 -vf pp [?]
169
+ Storage[UpConvertEnglish] = "high compress"
170
+ Storage[UpConvertKey] = "hqdn3d=7:7:5,pp=hb:y/vb:y,scale=SCREEN_X:-1:0:0:5"
171
+ Storage[UpConvertKeyExtra] = "-sws 9 -ssf ls=75.0 -ssf cs=75.0"
172
+ display_current_upconvert_setting
173
+ }
174
+ new_jbutton("set upconvert options to aggressive DVD/HQ-style playback") {
175
+ Storage[UpConvertKey] = "hqdn3d=7:7:5,scale=SCREEN_X:-1:0:0:10"
176
+ Storage[UpConvertKeyExtra] = "-sws 9 -ssf ls=100.0 -ssf cs=75.0"
177
+ Storage[UpConvertEnglish] = "Aggressive DVD/HQ"
178
+ display_current_upconvert_setting
179
+ }
180
+ display_current_upconvert_setting
181
+ end
182
+
183
+ def display_current_upconvert_setting
184
+ show_blocking_message_dialog "Current upconvert options set to #{Storage[UpConvertEnglish] || 'none'}"
185
+ end
186
+
187
+ def get_upconvert_vf_settings
188
+ template = Storage[UpConvertKey]
189
+ if template
190
+ x = java.awt.Toolkit.getDefaultToolkit().getScreenSize().get_width
191
+ outgoing = template.gsub('SCREEN_X', x.to_i.to_s) # has to be an integer...
192
+ outgoing
193
+ else
194
+ nil
195
+ end
196
+ end
148
197
 
149
- @create_new_edl_for_current_dvd = new_jbutton("Create new Delete List for a DVD", true,
198
+ def get_upconvert_secondary_settings
199
+ Storage[UpConvertKeyExtra]
200
+ end
201
+
202
+ def setup_advanced_buttons
203
+
204
+ add_text_line 'Realtime create Options:'
205
+
206
+ @create_new_edl_for_current_dvd = new_jbutton("Create new Edit List for a DVD",
150
207
  "If your DVD doesn't have an EDL created for it, this will be your first step--create an EDL file for it.")
151
208
  @create_new_edl_for_current_dvd.on_clicked do
152
209
  create_brand_new_edl
153
210
  end
154
211
 
155
- @open_list = new_jbutton("Open/Edit a previously created Delete List", true, "If your DVD has a previously existing EDL for it, you can open it to edit it with this button.")
212
+ @open_list = new_jbutton("Open/Edit a previously created EDL or .srt file", "If your DVD has a previously existing EDL for it, you can open it to edit it with this button.")
156
213
  @open_list.on_clicked {
157
- filename = new_existing_file_selector_and_select_file( "Pick file to edit", EDL_DIR)
214
+ filename = new_existing_file_selector_and_select_file( "Pick any file to open in editor", EDL_DIR)
158
215
  open_file_to_edit_it filename
159
216
  }
160
217
 
161
- @play_smplayer = new_jbutton( "Watch full DVD unedited (realtime smplayer)", true)
218
+
219
+ @create_dot_edl = new_jbutton( "Create an associatable moviefilename.edl file")
220
+ @create_dot_edl.tool_tip = <<-EOL
221
+ Create a moviefilename.edl file (corresponding to moviefilename.some_ext which already exists)
222
+ XBMC/smplayer (smplayer can be used by WMC plugins, etc.) "automagically detect",
223
+ if it exists, and automatically use it .edl to show that file edited played back.
224
+ If you use smplayer, note that you'll need to download the "lord mulder mplayer"
225
+ version (which includes an updated version of mplayer that fixes some bugs in EDL playback)
226
+ EOL
227
+ @create_dot_edl.on_clicked {
228
+ choose_file_and_edl true
229
+ }
230
+
231
+ @play_smplayer = new_jbutton( "Watch full DVD unedited (realtime smplayer)")
162
232
  @play_smplayer.tool_tip = <<-EOL
163
233
  This will play the DVD unedited within smplayer.
164
234
  NB it will default to title 1, so updated your EDL file that matches this DVD with the proper title if this doesn't work for you
@@ -172,7 +242,7 @@ module SensibleSwing
172
242
  play_dvd_smplayer_unedited
173
243
  }
174
244
 
175
- @play_mplayer_raw = new_jbutton( "Watch full DVD unedited (realtime mplayer)", true)
245
+ @play_mplayer_raw = new_jbutton( "Watch full DVD unedited (realtime mplayer)")
176
246
  @play_mplayer_raw.tool_tip = <<-EOL
177
247
  This is also useful for comparing subtitle files to see if they have accurate timings.
178
248
  If you turn on subtitles (use the v button), then compare your srt file at say, the 1 hour mark, or 2 hour mark,
@@ -183,23 +253,27 @@ module SensibleSwing
183
253
  play_dvd_smplayer_unedited true
184
254
  }
185
255
 
186
- # @watch_created_file = new_jbutton( "Watch the edited file version of DVD", false).on_clicked {
187
- # raise 'todo' # TODO
188
- # }
189
-
190
- # TODO button "Watch a file using an EDL on it"
191
-
192
-
193
- @display_unique = new_jbutton( "Display current DVD's unique ID", true )
256
+ @display_unique = new_jbutton( "Display current DVD's unique ID" )
194
257
  @display_unique.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."
195
258
  @display_unique.on_clicked {
196
- drive, volume, dvd_id = choose_dvd_drive_or_file true
259
+ drive, volume_name, dvd_id = choose_dvd_drive_or_file true
197
260
  # display it, allow them to copy and paste it out
198
- show_copy_pastable_string("#{drive} #{volume} for your copying+pasting pleasure (highlight, then ctrl+c to copy)\n
199
- This is USED to identify a disk to match it to its EDL, later.", "\"disk_unique_id\" => \"#{dvd_id}\",")
261
+ show_copy_pastable_string("#{drive} #{volume_name} for your copying+pasting pleasure (highlight, then ctrl+c to copy)\n
262
+ This is USED eventually to identify a disk to match it to its EDL, later.", "\"disk_unique_id\" => \"#{dvd_id}\", # #{volume_name}")
263
+ }
264
+
265
+ @convert_seconds_to_ts = new_jbutton( "Convert 3600 <-> 1:00:00 style timestamps" )
266
+ @convert_seconds_to_ts.on_clicked {
267
+ input = get_user_input("Enter \"from\" timestamps, like 3600 or 1:40:00:", "1:00:00.1 or 3600.1")
268
+ if input =~ /:/
269
+ output = EdlParser.translate_string_to_seconds input
270
+ else
271
+ output = EdlParser.translate_time_to_human_readable input.to_f, true
272
+ end
273
+ show_copy_pastable_string("Converted:", output)
200
274
  }
201
275
 
202
- @convert_timestamp = new_jbutton( "Convert timestamp from DVD player time to EDL time", true)
276
+ @convert_timestamp = new_jbutton( "Convert timestamp from DVD player time (30 fps) to EDL player time (29.97 fps)" )
203
277
  @convert_timestamp.tool_tip=<<-EOL
204
278
  Our EDL's assume 29.97 fps (which is what a DVD is). Unfortunately most hardware/commercial DVD players
205
279
  assume that the DVD is 30 fps, which means that if you watch a movie with them, then use those timestamps
@@ -218,10 +292,10 @@ module SensibleSwing
218
292
  thirty_fps_in_seconds = EdlParser.translate_string_to_seconds thirty_fps
219
293
  twenty_nine_seven_fps = ConvertThirtyFps.from_thirty(thirty_fps_in_seconds)
220
294
  human_twenty_nine_seven = EdlParser.translate_time_to_human_readable twenty_nine_seven_fps, true
221
- show_copy_pastable_string("29.97 (sensible cinema usable) value would be: ", human_twenty_nine_seven)
295
+ show_copy_pastable_string("Sensible cinema usable value (29.97 fps) for #{thirty_fps} would be: ", human_twenty_nine_seven)
222
296
  }
223
297
 
224
- @parse_srt = new_jbutton("Parse a subtitle file (.srt) to detect profanities", true)
298
+ @parse_srt = new_jbutton("Parse a subtitle file (.srt) to detect profanities" )
225
299
  @parse_srt.tool_tip = <<-EOL
226
300
  You can download a .srt file and parse it to automaticaly search for profanities.
227
301
  Basically download it from opensubtitles.org (possibly from other places, too),
@@ -231,36 +305,38 @@ module SensibleSwing
231
305
  @parse_srt.on_clicked {
232
306
  filename = new_existing_file_selector_and_select_file("Pick srt file:")
233
307
  parsed = SubtitleProfanityFinder.edl_output [filename]
234
- File.write(EdlTempFile, "# add these into your mute section if they apply\n" + parsed)
308
+ File.write(EdlTempFile, "# add these into your mute section if they are offensive\n" + parsed)
235
309
  open_file_to_edit_it EdlTempFile
236
310
  }
311
+
312
+ add_set_upconvert_options_button
237
313
 
238
314
  add_text_line 'Create Options that first create/use a local intermediary file:'
239
315
 
240
- @preview_section = new_jbutton( "Preview a certain time frame from fulli file (edited)", true )
316
+ @preview_section = new_jbutton( "Preview a certain time frame from fulli file (edited)" )
241
317
  @preview_section.tool_tip = <<-EOL
242
318
  This allows you to preview an edit easily.
243
319
  It is the equivalent of saying \"watch this file edited from exactly minute x second y to minute z second q"
244
320
  Typically if you want to test an edit, you can start a few seconds before, and end a few seconds after it, to test it precisely.
245
321
  EOL
246
322
  @preview_section.on_clicked {
247
- do_copy_dvd_to_hard_drive true
323
+ do_copy_dvd_to_hard_drive_via_file true
248
324
  }
249
325
 
250
- @preview_section_unedited = new_jbutton("Preview a certain time frame from fulli file (unedited)", true)
326
+ @preview_section_unedited = new_jbutton("Preview a certain time frame from fulli file (unedited)" )
251
327
  @preview_section.tool_tip = "Allows you to view a certain time frame unedited (ex: 10:00 to 10:05), so you can narrow down to pinpoint where questionable scenes are, etc. This is the only way to view a specific scene if there are not cuts within that scene yet."
252
328
  @preview_section_unedited.on_clicked {
253
- do_copy_dvd_to_hard_drive true, false, true
329
+ do_copy_dvd_to_hard_drive_via_file true, false, true
254
330
  }
255
331
 
256
- @rerun_preview = new_jbutton( "Re-run most recently watched preview time frame from fulli file", true )
332
+ @rerun_preview = new_jbutton( "Re-run most recently watched preview time frame from fulli file" )
257
333
  @rerun_preview.tool_tip = "This will re-run the preview that you most recently performed. Great for checking to see if you last edits were successful or not."
258
334
  @rerun_preview.on_clicked {
259
335
  repeat_last_copy_dvd_to_hard_drive
260
336
  }
261
337
 
262
338
  # Maybe this button should go too...
263
- @fast_preview = new_jbutton("fast preview all from fulli file (smplayer EDL)", true)
339
+ @fast_preview = new_jbutton("fast preview all from fulli file (smplayer EDL)")
264
340
  @fast_preview.tool_tip = <<-EOL
265
341
  Plays smplayer on a file with an EDL.
266
342
  This gives you a rough estimate to see if your edits are accurate, and is really fast to seek, etc.
@@ -268,26 +344,66 @@ module SensibleSwing
268
344
  timestamp splits in it [because some DVD's are buggy]
269
345
  EOL
270
346
  @fast_preview.on_clicked {
271
- success, wrote_to_here_fulli = do_copy_dvd_to_hard_drive false, true
347
+ success, wrote_to_here_fulli = do_copy_dvd_to_hard_drive_via_file false, true
272
348
  sleep 0.5 # lodo take out ???
273
349
  background_thread.join if background_thread # let it write out the original fulli, if necessary [?]
274
- nice_file = wrote_to_here_fulli #+ ".fast.mpg"
275
- if false#!File.exist?(nice_file)
276
- p = show_non_blocking_message_dialog("Creating quick lookup file--NB that for each changed deletion setting,
277
- you'll need to save your file and restart the fast preview SMplayer instance.
278
- Also note that the start and end times will be slightly off if reality [delayed]
279
- Also note that while doing fast preview, it can be doing a normal preview as well
280
- in the background, simultaneously.")
281
- unless system_blocking("ffmpeg -i #{wrote_to_here_fulli} -target ntsc-dvd #{nice_file}")
282
- File.delete nice_file
283
- raise 'create '
284
- end
285
- p.dispose # it will be active for sure
286
- end
287
- set_smplayer_opts "-edl #{EdlTempFile}"
288
- thread = do_mplayer_edl( "smplayer_portable #{nice_file}") # note the smplayer, but it's for the fast file...
350
+ nice_file = wrote_to_here_fulli
351
+ run_smplayer_blocking nice_file, "-edl \"#{EdlTempFile}\"", false
352
+ }
353
+
354
+ end # advanced buttons
355
+
356
+ def setup_normal_buttons
357
+
358
+ @mplayer_edl = new_jbutton( "Watch DVD/file edited on computer (realtime -- mplayer EDL)")
359
+ @mplayer_edl.tool_tip = "This will watch your DVD in realtime from your computer while skipping/muting questionable scenes."
360
+ @mplayer_edl.on_clicked {
361
+ play_mplayer_edl
362
+ }
363
+
364
+ @create = new_jbutton( "Create edited copy version of video on Your Hard Drive" )
365
+ @create.tool_tip = <<-EOL
366
+ This grabs from your DVD and creates a new file on your hard disk like dvd_name_edited.mpg for you to watch later.
367
+ The file you create will contain the whole movie edited.
368
+ It takes quite awhile maybe 2 hours. Sometimes the progress bar will look paused--it will continue eventually.
369
+ EOL
370
+ @create.on_clicked {
371
+ do_copy_dvd_to_hard_drive_via_file false
289
372
  }
290
373
 
374
+ @open_help_file = new_jbutton("View Sensible Cinema Documentation") do
375
+ show_in_explorer __DIR__ + "/../documentation"
376
+ end
377
+
378
+ # @watch_created_file = new_jbutton( "Watch the edited file version of DVD", false).on_clicked {
379
+ # play_mplayer_edl # TODO
380
+ # }
381
+
382
+ @watch_file_edl = new_jbutton( "Watch a file edited (realtime)" ) do
383
+ choose_file_and_edl false
384
+ end
385
+
386
+ end
387
+
388
+ def choose_file_and_edl just_create_dot_edl_file_instead_of_play
389
+ filename_mpg = new_existing_file_selector_and_select_file( "pick moviefile (like moviename.mpg)")
390
+ edl_filename = new_existing_file_selector_and_select_file( "Pick an EDL file to use with it", EDL_DIR)
391
+ assert_ownership_dialog
392
+ if just_create_dot_edl_file_instead_of_play
393
+ descriptors = EdlParser.parse_file edl_filename
394
+ # LODO these timings...DRY up...plus is XBMC the same? what about on a slower computer?
395
+ edl_contents = MplayerEdl.convert_to_edl descriptors, add_secs_end = 0.0, add_secs_beginning = 0.5, splits = []
396
+ output_file = filename_mpg.gsub(/\.[^\.]+$/, '') + '.edl'
397
+ File.write(output_file, edl_contents)
398
+ raise unless File.exist?(output_file)
399
+ show_blocking_message_dialog("created #{output_file}")
400
+ else
401
+ play_mplayer_edl [filename_mpg, edl_filename]
402
+ end
403
+ end
404
+
405
+ def we_are_in_upconvert_mode
406
+ ARGV.index("--upconvert-mode")
291
407
  end
292
408
 
293
409
  def initialize
@@ -301,80 +417,85 @@ module SensibleSwing
301
417
  @panel = panel
302
418
  @buttons = []
303
419
  panel.set_layout nil
304
- add panel # why can't I just slap these down?
305
-
306
- jlabel = JLabel.new 'Welcome to Sensible Cinema!' + (we_are_in_create_mode ? " Hover over buttons for tooltip \"help\" descriptions." : "")
307
- happy = Font.new("Tahoma", Font::PLAIN, 11)
308
- jlabel.setFont(happy)
309
- jlabel.set_bounds(44,44,460,14)
310
- panel.add jlabel
311
- @starting_button_y = 120
420
+ add panel # why can't I just slap these down? panel? huh?
421
+ @starting_button_y = 40
312
422
  @button_width = 400
313
423
 
314
- ## BUTTONS ##
315
-
316
- @mplayer_edl = new_jbutton( "Watch DVD/file edited on computer (realtime -- mplayer EDL)", false)
317
- @mplayer_edl.tool_tip = "This will watch your DVD in realtime from your computer while skipping/muting the questionable scenes."
318
- @mplayer_edl.on_clicked {
319
- do_mplayer_edl
320
- }
424
+ add_text_line "Welcome to Sensible Cinema!"
425
+ @starting_button_y += 10 # kinder ugly...
426
+ add_text_line " Rest mouse over buttons for \"help\" type descriptions (tooltips)."
427
+ add_text_line ""
428
+ add_text_line ""
321
429
 
322
- @create = new_jbutton( "Create edited copy of a DVD's file on Your Hard Drive", false)
323
- @create.tool_tip = <<-EOL
324
- This grabs from your DVD and creates a new file on your hard disk like dvd_name_edited.mpg for you to watch later.
325
- The file you create will contain the whole movie edited.
326
- It takes quite awhile maybe 2 hours.
327
- EOL
328
- @create.on_clicked {
329
- do_copy_dvd_to_hard_drive false
330
- }
331
-
332
- @open_help_file = new_jbutton("View Sensible Cinema Documentation", false).on_clicked do
333
- system_blocking("explorer \"#{__DIR__.to_filename}..\\documentation\"") rescue nil # declares it fails, in error...
334
- end
335
-
336
- setup_advanced_buttons
430
+ if we_are_in_upconvert_mode
431
+ setup_upconvert_buttons
432
+ else
433
+ setup_normal_buttons
337
434
 
338
- add_text_line 'Contact:'
339
-
340
- @upload = new_jbutton("Submit feedback/Upload Anything/Request Help", false) # keep this one last! :)
341
- @upload.tool_tip = "We welcome all feedback!\nQuestion, comments, request help.\nAlso if you create a new EDL, please submit it back to us so that others can benefit from it later!"
342
- @upload.on_clicked {
343
- system_non_blocking("start mailto:sensible-cinema@googlegroups.com")
344
- system_non_blocking("start http://groups.google.com/group/sensible-cinema")
345
- }
435
+ if we_are_in_create_mode
436
+ setup_advanced_buttons
437
+ add_text_line 'Contact:'
438
+ end
346
439
 
440
+ @upload = new_jbutton("Submit feedback/Upload/Request Help") # keep this one last! :)
441
+ @upload.tool_tip = "We welcome all feedback!\nQuestion, comments, request help.\nAlso if you create a new EDL, please submit it back to us so that others can benefit from it later!"
442
+ @upload.on_clicked {
443
+ system_non_blocking("start mailto:sensible-cinema@googlegroups.com")
444
+ system_non_blocking("start http://groups.google.com/group/sensible-cinema")
445
+ }
347
446
 
348
-
349
- @progress_bar = JProgressBar.new(0, 100)
350
- @progress_bar.set_bounds(44,@starting_button_y,@button_width,23)
351
- @progress_bar.visible = false
352
- panel.add @progress_bar
447
+ @progress_bar = JProgressBar.new(0, 100)
448
+ @progress_bar.set_bounds(44,@starting_button_y,@button_width,23)
449
+ @progress_bar.visible = false
450
+ panel.add @progress_bar
451
+
452
+ increment_button_location
353
453
 
354
- increment_button_location
355
- increment_button_location
454
+ end
356
455
 
357
- @exit = new_jbutton("Exit", false, "Exits the application and kills any background processes that are running at all--don't exit unless you are done processing all the way!")
456
+ @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!")
358
457
  @exit.on_clicked {
359
458
  Thread.new { self.close } # don't waste the time to close it :P
360
- kill_processes
361
- puts 'Thank you for using Sensible Cinema.'
459
+ puts 'Thank you for using Sensible Cinema. Goodbye.'
362
460
  java.lang.System.exit 0
363
461
  }
364
462
 
365
463
  increment_button_location
366
464
  increment_button_location
367
465
 
368
- setSize @button_width+80, @starting_button_y
369
466
  setIconImage(ImageIcon.new(__dir__ + "/../vendor/monkey.png").getImage())
370
- check_for_dependencies
467
+ check_for_various_dependencies
468
+ end
469
+
470
+ def run_smplayer_blocking play_this, extra_options, force_use_mplayer
471
+ extra_options += " -mouse-movements #{get_upconvert_secondary_settings} " # just in case smplayer also needs -mouse-movements... :)
472
+ if OS.mac? || force_use_mplayer
473
+ @_run_smplayer_instructions ||= show_mplayer_instructions
474
+ conf_file = File.expand_path('~') + '/.mplayer_input_conf'
475
+ File.write conf_file, "MOUSE_BTN0_DBL vo_fullscreen\nKP_ENTER dvdnav select\n" # dvdnav doesn't work here...
476
+ if OS.windows?
477
+ # direct3d for windows 7 old nvidia cards' sake [yipes]
478
+ extra_mplayer_commands << "-vo direct3d" # ?? directx ??
479
+ options += " -font #{ENV['SystemRoot']}\\fonts\\ARIAL.TTF " # would need EXTRA ESCAPING FOR SMPLAYER USE
480
+ end
481
+ c = "mplayer \"#{play_this}\" #{extra_options} #{"-vf " + get_upconvert_vf_settings if get_upconvert_vf_settings} -input conf=\"#{conf_file}\" -mouse-movements "
482
+ else
483
+ config_path = set_smplayer_opts extra_options
484
+ c = "smplayer_portable \"#{play_this}\" -config-path \"#{File.dirname config_path}\" -close-at-end "
485
+ end
486
+ puts c
487
+ system_blocking c
371
488
  end
372
489
 
373
- def set_smplayer_opts to_this
490
+ def set_smplayer_opts to_this, show_subs = false
374
491
  smplayer_prefs_file = File.expand_path("~/.smplayer/smplayer.ini")
375
492
  old_prefs = File.read(smplayer_prefs_file) rescue ''
376
- old_prefs = "[advanced]\nmplayer_additional_options=" unless old_prefs.contain? 'mplayer_additional_options='
493
+ old_prefs = "[advanced]\nmplayer_additional_options=\nmplayer_additional_video_filters=\n[subtitles]\nautoload_sub=false\n[performance]\npriority=3" unless old_prefs.contain? 'mplayer_additional_options='
377
494
  new_prefs = old_prefs.gsub(/mplayer_additional_options=.*/, "mplayer_additional_options=#{to_this}")
495
+ new_prefs.gsub!(/autoload_sub=.*$/, "autoload_sub=#{show_subs.to_s}")
496
+ p 'put upconvert options in as vf', get_upconvert_vf_settings
497
+ new_prefs.gsub!(/mplayer_additional_video_filters=.*$/, "mplayer_additional_video_filters=\"#{get_upconvert_vf_settings}\"")
498
+ new_prefs.gsub!(/priority=.*$/, "priority=3") # normal priority...scary otherwise! lodo tell smplayer...
378
499
  FileUtils.mkdir_p File.dirname(smplayer_prefs_file) # case it doesn't exist'
379
500
  File.write(smplayer_prefs_file, new_prefs)
380
501
  smplayer_prefs_file
@@ -402,10 +523,10 @@ module SensibleSwing
402
523
  "dvd_title_track" => "1", # most DVD's use title 1. Not all do, though. If sensible-cinema plays anything except the main title (for example, it plays a trailer), when you use it, see http://goo.gl/QHLIF to set this right.
403
524
  # "not edited out stuff" => "some violence",
404
525
  # "closing thoughts" => "still...",
405
- # "mplayer_dvd_splits" => ["59:59", "1:04:59"], # in mplayer, the DVD timestamp "resets" to zero for some reason, see http://goo.gl/yMfqX to set this value right. Note that [] is valid, if there are no resets.
526
+ # "mplayer_dvd_splits" => ["59:59", "1:04:59"], # or [] if there are none. In mplayer, the DVD timestamp "resets" to zero for some reason, so you need to specify when if you want to use mplayer DVD realtime playback, or use mencoder -edl to split your file. See http://goo.gl/yMfqX
406
527
  EOL
407
528
  # frame0 is the name of our window LOL tough to avoid that collision...hmm...
408
- filename = EDL_DIR + "\\" + english_name.gsub(' ', '_') + '.txt'
529
+ filename = EDL_DIR + "\\edls_being_edited\\" + english_name.gsub(' ', '_') + '.txt'
409
530
  filename.downcase!
410
531
  File.write(filename, input) unless File.exist?(filename) # lodo let them choose name (?)
411
532
  open_file_to_edit_it filename
@@ -460,71 +581,83 @@ module SensibleSwing
460
581
  writeOut.close
461
582
  end
462
583
 
463
- def _dbg
464
- require 'ruby-debug'
465
- debugger
466
- end
467
-
468
584
  def play_dvd_smplayer_unedited use_mplayer_instead = false
469
585
  # LODO really even if there are 2 it should still pick out the title track...hmm...on demand :P
470
- # lodo mac os x 'ify'
471
586
  drive, dvd_volume_name, dvd_id, edl_path_maybe_nil, descriptors_maybe_nil = choose_dvd_or_file_and_edl_for_it false
472
587
  if descriptors_maybe_nil
473
588
  title_track_maybe_nil = get_title_track(descriptors_maybe_nil, false)
474
589
  end
475
- if use_mplayer_instead
476
- exe = "mplayer "
477
- # maybe, maybe following would be useful for people just watching through the film (?)
478
- #"-font #{ENV['SystemRoot']}\\fonts\\ARIAL.TTF "
479
- else
480
- config_path = set_smplayer_opts " " # smplayer doesn't take -osdlevel 2 sniff...
481
- exe = "smplayer_portable -config-path \"#{File.dirname config_path}\" "
482
- end
483
- command = "#{exe} dvdnav://#{title_track_maybe_nil}/#{drive} -osd-fractions 2 -mouse-movements -nocache "
484
- p command
485
- @play_smplayer_warn ||= show_non_blocking_message_dialog "Directions:
486
- 'o' key: turn on on-screen-display timestamps (note: these are 30 fps timestamps so will need to be converted to use).
487
- 'v' key: turn off subtitles.
488
- '.' key: step one frame.
489
- 'f' for full screen."
490
- system_non_blocking command
590
+ file_to_play = "dvdnav://#{title_track_maybe_nil}/#{drive}"
591
+ options = " -osd-fractions 2 -nocache "
592
+ # want this even with smplayer I guess...
593
+ @play_smplayer_warn ||= show_mplayer_instructions <<-EOL
594
+ 'o' key: turn on on-screen-display timestamps (note: the OSD timestamps [upper left] are 30 fps so will need to be converted to use).
595
+ 'v' key: turn off subtitles.
596
+ '.' key: step one frame.
597
+ EOL
598
+
599
+ Thread.new { run_smplayer_blocking file_to_play, options, use_mplayer_instead }
600
+
491
601
  end
492
602
 
493
603
  EdlTempFile = Dir.tmpdir + '/mplayer.temp.edl'
494
604
 
495
- def do_mplayer_edl play_this_mplayer = nil, add_secs_end = 0, add_secs_beginning = 0.5
496
- drive_or_file, dvd_volume_name, dvd_id, edl_path, descriptors = choose_dvd_or_file_and_edl_for_it
497
- if dvd_id == NonDvd
498
- play_this_mplayer ||= "mplayer \"#{drive_or_file}\"" # play the file instead...
605
+ def show_mplayer_instructions extra = ''
606
+ show_non_blocking_message_dialog <<-EOL + extra
607
+ About to run mplayer.
608
+ To control it, use
609
+ spacebar : pause,
610
+ double clicky : toggle full screen,
611
+ arrow keys (left, right, up down) to seek/scan
612
+ / and * : inc/dec volume.
613
+ EOL
614
+ end
615
+
616
+ def play_mplayer_edl file_with_edl_path = nil
617
+ add_secs_end = 0
618
+ add_secs_beginning = 0.5 # LODO are these accurate for file based, as well?
619
+ extra_mplayer_commands = []
620
+ if file_with_edl_path
621
+ drive_or_file, edl_path = file_with_edl_path
622
+ dvd_id = NonDvd # fake it out...
623
+ # descriptors = {} # allow unkon
624
+ else
625
+ drive_or_file, dvd_volume_name, dvd_id, edl_path, descriptors = choose_dvd_or_file_and_edl_for_it
499
626
  end
500
- descriptors = EdlParser.parse_file edl_path
501
- splits = descriptors['mplayer_dvd_splits']
502
- if splits == nil && !play_this_mplayer
503
- show_blocking_message_dialog("warning: delete list does not contain mplayer replay information [mplayer_dvd_splits] so edits past a certain time period might not won't work ( http://goo.gl/yMfqX ).")
504
- splits = []
627
+ if dvd_id == NonDvd
628
+ play_this = drive_or_file # play straight file...
629
+ else
630
+ using_dvd = true
631
+ title_track = get_title_track(descriptors)
632
+ extra_mplayer_commands << "-nocache"
633
+ play_this = "dvdnav://#{title_track}/#{drive_or_file}"
505
634
  end
506
- splits.map!{|s| EdlParser.translate_string_to_seconds(s) }
507
- edl_contents = MplayerEdl.convert_to_edl descriptors, add_secs_end, add_secs_beginning, splits # add a sec to mutes to accomodate for mplayer's oddness...
508
- File.write(EdlTempFile, edl_contents)
509
- title_track = get_title_track(descriptors)
510
- # oh the insanity of the console UI...LODO more user friendly player
511
- @popup ||= show_non_blocking_message_dialog("About to run mplayer EDL. To control it, use\n space for pause,\n f for full screen,\n arrow keys to seek.")
512
- # LODO dry up mplayer dvd opts...
513
- if OS.windows?
514
- play_this_mplayer ||= "mplayer -mouse-movements -nocache dvdnav://#{title_track} "
635
+ if edl_path
636
+ descriptors = EdlParser.parse_file edl_path
515
637
  else
516
- # macports' mplayer has no dvdnav ??
517
- play_this_mplayer ||= "mplayer dvd://#{title_track} "
638
+ descriptors = {}
518
639
  end
519
- if OS.windows?
520
- # direct3d for windows 7 old nvidia's sake yipes
521
- play_this_mplayer += " -vo direct3d "
522
- play_this_mplayer += " -font #{ENV['SystemRoot']}\\fonts\\ARIAL.TTF"
640
+ if using_dvd
641
+ splits = descriptors['mplayer_dvd_splits']
642
+ splits ||= []
643
+ if splits == []
644
+ show_blocking_message_dialog("warning: edit list does not contain mplayer replay information [mplayer_dvd_splits] so edits past a certain time period might not won't work ( http://goo.gl/yMfqX ).")
645
+ end
646
+ splits.map!{|s| EdlParser.translate_string_to_seconds(s) }
647
+ else
648
+ splits = []
523
649
  end
524
- command = "#{play_this_mplayer} -framedrop -alang en -sid 1000 -edl #{File.expand_path EdlTempFile} -dvd-device #{drive_or_file}"
650
+ edl_contents = MplayerEdl.convert_to_edl descriptors, add_secs_end, add_secs_beginning, splits#, 600 TODOS # add a sec to mutes to accomodate for mplayer's oddness...
651
+ File.write(EdlTempFile, edl_contents)
652
+
653
+ # -framedrop is for slow CPU's
654
+ # same with -autosync to try and help it stay in sync... -mc 0.03 is to A/V correct 1s audio per 2s video
525
655
  # -hardframedrop might help but hurts just too much
526
- p command
527
- Thread.new { system_blocking command; @popup.dispose }
656
+ extra_mplayer_commands << "-framedrop -mc 0.016 -autosync 15"
657
+ extra_mplayer_commands << "-alang en -nosub -noautosub -forcedsubsonly -sid 1000 -edl #{File.expand_path EdlTempFile}" # some maybe no longer necessary, but avoid subtitles by default...
658
+
659
+ # LODO -fullscreen ...
660
+ Thread.new { run_smplayer_blocking play_this, extra_mplayer_commands.join(' '), false}
528
661
  end
529
662
 
530
663
  def assert_ownership_dialog
@@ -552,7 +685,7 @@ module SensibleSwing
552
685
 
553
686
  returned = JOptionPane.showConfirmDialog self, message, title, JOptionPane::YES_NO_CANCEL_OPTION
554
687
  assert_confirmed_dialog returned, license_url_should_also_be_embedded_by_you_in_message
555
- p 'confirmed license noted: ' + license_name
688
+ p 'confirmation of sensible cinema related license noted of: ' + license_name
556
689
  throw unless returned == 0
557
690
  old.each{|name, old_setting| UIManager.put(name, old_setting)}
558
691
  end
@@ -577,7 +710,6 @@ module SensibleSwing
577
710
  System.exit 1
578
711
  end
579
712
  end
580
-
581
713
 
582
714
  def print *args
583
715
  Kernel.print *args # avoid bin\sensible-cinema.rb:83:in `system_blocking': cannot convert instance of class org.jruby.RubyString to class java.awt.Graphics (TypeError)
@@ -594,7 +726,7 @@ module SensibleSwing
594
726
  end
595
727
  end
596
728
 
597
- def download_zip_to english_name, url, to_this
729
+ def download_zip_file_and_extract english_name, url, to_this
598
730
  download_7zip
599
731
  Dir.chdir('vendor/cache') do
600
732
  file_name = url.split('/')[-1]
@@ -606,48 +738,46 @@ module SensibleSwing
606
738
  end
607
739
  end
608
740
 
609
- require 'lib/check_installed_mac.rb'
610
-
611
741
  def check_for_exe windows_loc, unix_name
612
742
  # in windows, that exe *at that location* must exist...
613
743
  if OS.windows?
614
744
  File.exist?(windows_loc)
615
745
  else
746
+ require 'lib/check_installed_mac.rb'
616
747
  if !CheckInstalledMac.check_for_installed(unix_name)
617
- exit 1
748
+ exit 1 # it'll have already displayed a message...
618
749
  else
619
750
  true
620
751
  end
621
752
  end
622
753
  end
623
754
 
624
- def check_for_dependencies
625
- ffmpeg_exe_loc = File.expand_path('vendor/cache/ffmpeg/ffmpeg.exe')
626
- if !check_for_exe(ffmpeg_exe_loc, 'ffmpeg')
627
- require_blocking_license_accept_dialog 'ffmpeg', 'gplv2', 'http://www.gnu.org/licenses/gpl-2.0.html', "Appears that you need to install a dependency: ffmpeg."
628
- download_zip_to "ffmpeg (5MB)", "http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-git-1929807-win32-shared.7z", "ffmpeg"
629
- end
630
-
631
- if !check_for_exe('vendor/cache/mencoder/mencoder.exe', 'mencoder')
632
- require_blocking_license_accept_dialog 'mplayer', 'gplv2', 'http://www.gnu.org/licenses/gpl-2.0.html', "Appears that you need to install a dependency: mplayer with mencoder."
633
- download_zip_to "Mplayer/mencoder (6MB)", "http://downloads.sourceforge.net/project/mplayer-win32/MPlayer%20and%20MEncoder/revision%2033574/MPlayer-rtm-svn-33574.7z", "mencoder"
634
- end
635
-
755
+ def check_for_various_dependencies
636
756
  if we_are_in_create_mode
637
- # they're going to want these dependencies
638
- if OS.windows?
639
- path = RubyWhich.new.which('smplayer_portable')
640
- if(path.length == 0)
641
- # this one has its own installer...
642
- show_blocking_message_dialog("It appears that you need to install a dependency: MPlayer for Windows (MPUI).\n
643
- Click ok to be directed to its download website, where you can download and install it (recommend: MPUI Full-package), then restart sensible cinema.",
644
- "Lacking dependency", JOptionPane::ERROR_MESSAGE)
645
- system_non_blocking("start http://mulder.dummwiedeutsch.de/#mplayer") # LODO would launchy help/work here with the full url?
646
- System.exit(1)
647
- end
648
- else
649
- check_for_exe("mplayer", "mplayer") # OS X ...
650
- puts 'warning for OS X users--the smplayer-type buttons aren\'t going to work'
757
+ ffmpeg_exe_loc = File.expand_path('vendor/cache/ffmpeg/ffmpeg.exe')
758
+ if !check_for_exe(ffmpeg_exe_loc, 'ffmpeg')
759
+ require_blocking_license_accept_dialog 'ffmpeg', 'gplv2', 'http://www.gnu.org/licenses/gpl-2.0.html', "Appears that you need to install a dependency: ffmpeg."
760
+ download_zip_file_and_extract "ffmpeg (5MB)", "http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-git-1929807-win32-shared.7z", "ffmpeg"
761
+ end
762
+
763
+ if !check_for_exe('vendor/cache/mencoder/mencoder.exe', 'mencoder')
764
+ require_blocking_license_accept_dialog 'mplayer', 'gplv2', 'http://www.gnu.org/licenses/gpl-2.0.html', "Appears that you need to install a dependency: mplayer with mencoder."
765
+ download_zip_file_and_extract "Mplayer/mencoder (6MB)", "http://downloads.sourceforge.net/project/mplayer-win32/MPlayer%20and%20MEncoder/revision%2033574/MPlayer-rtm-svn-33574.7z", "mencoder"
766
+ end
767
+ end
768
+
769
+ # runtime dependencies, at least today...
770
+ if OS.mac?
771
+ check_for_exe("mplayer", "mplayer") # mencoder and mplayer are separate for mac... [this checks for mac's mplayerx, too]
772
+ else
773
+ path = RubyWhich.new.which('smplayer_portable')
774
+ if(path.length == 0)
775
+ # this one has its own installer...
776
+ show_blocking_message_dialog("It appears that you need to install a dependency: MPlayer for Windows (MPUI).\n
777
+ Click ok to be directed to its download website, where you can download and install it (recommend: MPUI Full-package), then restart sensible cinema.",
778
+ "Lacking dependency", JOptionPane::ERROR_MESSAGE)
779
+ system_non_blocking("start http://mulder.dummwiedeutsch.de/#mplayer") # LODO would launchy help/work here with the full url?
780
+ System.exit(1)
651
781
  end
652
782
  end
653
783
  end
@@ -661,11 +791,11 @@ module SensibleSwing
661
791
  end
662
792
 
663
793
  def single_edit_list_matches_dvd dvd_id
664
- matching = Dir[EDL_DIR + '/*.txt'].select{|file|
794
+ matching = Dir[EDL_DIR + '/**/*.txt'].select{|file|
665
795
  begin
666
796
  parse_edl(file)["disk_unique_id"] == dvd_id
667
797
  rescue SyntaxError => e
668
- # ignore poorly formed delete lists for the auto choose phase...
798
+ # ignore poorly formed edit lists for the auto choose phase...
669
799
  p 'warning, unable to parse a file:' + file + " " + e.to_s
670
800
  false
671
801
  end
@@ -726,7 +856,7 @@ module SensibleSwing
726
856
  end
727
857
 
728
858
  def new_existing_file_selector_and_select_file title, dir=nil
729
- out = FileDialog.new(self)
859
+ out = FileDialog.new(self, title, FileDialog::LOAD)
730
860
  out.set_title title
731
861
  dir ||= Storage[caller.inspect]
732
862
  out.set_directory dir.to_filename if dir
@@ -736,13 +866,13 @@ module SensibleSwing
736
866
  got
737
867
  end
738
868
 
739
- def choose_dvd_or_file_and_edl_for_it force_choose_edl_file = true
869
+ def choose_dvd_or_file_and_edl_for_it force_choose_edl_file_if_no_easy_match = true
740
870
  drive_or_file, dvd_volume_name, dvd_id = choose_dvd_drive_or_file false
741
871
 
742
872
  unless @_edit_list_path # cache file selection...
743
873
  edit_list_path = single_edit_list_matches_dvd(dvd_id)
744
- if !edit_list_path && force_choose_edl_file
745
- edit_list_path = new_existing_file_selector_and_select_file("Please pick a DVD Delete List File (none were found that seem to match #{dvd_volume_name})--may need to create one for it", EDL_DIR)
874
+ if !edit_list_path && force_choose_edl_file_if_no_easy_match
875
+ edit_list_path = new_existing_file_selector_and_select_file("Please pick a DVD Edit List File (none or more than one were found that seem to match #{dvd_volume_name})--may need to create one for it", EDL_DIR)
746
876
  raise 'cancelled choosing an EDL' unless edit_list_path
747
877
  end
748
878
  @_edit_list_path = edit_list_path
@@ -772,39 +902,37 @@ module SensibleSwing
772
902
  def get_import_from_filename dvd_title, dvd_title_track
773
903
  @_get_import_from_filename ||=
774
904
  begin
775
- new_existing_file_selector_and_select_file "Please choose the file that is your ripped version of #{dvd_title} title ##{dvd_title_track} (.mpg or .ts--see documentation/how_to_get_files_from_dvd.txt file)"
905
+ new_existing_file_selector_and_select_file "Please choose the file that is your ripped equivalent of #{dvd_title} (title track #{dvd_title_track}) (.mpg or .ts--see file documentation/how_to_get_files_from_dvd.txt)"
776
906
  end
777
907
  end
778
908
 
779
909
  def get_save_to_filename dvd_title
780
910
  @_get_save_to_filename ||=
781
911
  begin
782
- fc = new_nonexisting_filechooser "Pick where to save #{dvd_title} edited version as"
912
+ fc = new_nonexisting_filechooser "Pick where to save #{dvd_title} edited version to"
783
913
  save_to_file_name = dvd_title + ' edited version'
784
- save_to_file_name = save_to_file_name.gsub(' ', '_').gsub( /\W/, '') # no punctuation or spaces for now...
914
+ save_to_file_name = save_to_file_name.gsub(' ', '_').gsub( /\W/, '') + ".avi" # no punctuation or spaces for now, to not complicate...
785
915
  fc.set_file(get_drive_with_most_space_with_slash + save_to_file_name)
786
916
  save_to = fc.go
917
+ raise 'no spaces allowed yet' if save_to =~ / /
787
918
  begin
788
- FileUtils.touch save_to
789
- File.delete save_to
919
+ a = File.open(File.dirname(save_to) + "/test_file_to_see_if_we_have_permission_to_write_to_this_folder", "w")
920
+ a.close
921
+ File.delete a.path
790
922
  rescue Errno::EACCES => e
791
923
  show_blocking_message_dialog "unable to write to that directory, please pick again: " + e.to_s
792
924
  raise 'pick again!'
793
925
  end
794
- a = File.open(File.dirname(save_to) + "/test_file_to_see_if_we_have_permission_to_write_to_this_folder", "w")
795
- a.close
796
- File.delete a.path
797
926
  freespace = get_freespace(save_to)
798
927
  if freespace < 8_000_000_000
799
928
  show_blocking_message_dialog("Warning: there may not be enough space on the disk for #{save_to}
800
929
  (depending on DVD size, you may need around 10G free--you have #{freespace/1_000_000_000}GB free). Click OK to continue.")
801
930
  end
802
- raise 'cannot save to filname with spaces yet (ask for it)' if save_to =~ / /
803
- save_to
931
+ save_to.gsub(/\.avi$/, '')
804
932
  end
805
933
  end
806
934
 
807
- def do_copy_dvd_to_hard_drive should_prompt_for_start_and_end_times, exit_early_if_fulli_exists = false, watch_unedited = false
935
+ def do_copy_dvd_to_hard_drive_via_file should_prompt_for_start_and_end_times, exit_early_if_fulli_exists = false, watch_unedited = false
808
936
  drive_or_file, dvd_volume_name, dvd_id, edit_list_path, descriptors = choose_dvd_or_file_and_edl_for_it
809
937
 
810
938
  descriptors = parse_edl(edit_list_path)
@@ -821,7 +949,7 @@ module SensibleSwing
821
949
  For example, if it mutes from second 1 to second 10, you'll want to play from 00:00 to 00:12 or what not.
822
950
  Also note that the first time you preview a section of a video, it will take a long time (like an hour) as it sets up the entire video for processing.
823
951
  Subsequent previews will be faster, though, as long as you use the same filename, as it won't have to re-set it up for processing.
824
- Also note that if you change your delete list, you'll need to close, and restart the video to be able to see it with your new settings.
952
+ Also note that if you change your edit list, you'll need to close, and restart the video to be able to see it with your new settings.
825
953
  EOL
826
954
  old_start = Storage['start_time']
827
955
  start_time = get_user_input("At what point in the video would you like to start your preview? (like 01:00 for starting at 1 minute)", Storage['start_time'])
@@ -843,10 +971,11 @@ module SensibleSwing
843
971
 
844
972
  dvd_title_track = get_title_track(descriptors)
845
973
  if dvd_id == NonDvd
846
- file_from = drive_or_file
974
+ file_from = drive_or_file
847
975
  else
848
976
  file_from = get_import_from_filename dvd_friendly_name, dvd_title_track # we don't even care about the drive letter anymore...
849
977
  end
978
+ show_blocking_message_dialog("warning: file is not a .mpg or .ts file--it may not work properly all the way--if it's mkv and fails consider first converting to ts by using tsmuxer.") unless file_from =~ /\.(ts|mpg|mpeg)$/i
850
979
  save_to_edited = get_save_to_filename dvd_friendly_name
851
980
  fulli = MencoderWrapper.calculate_fulli_filename save_to_edited
852
981
  if exit_early_if_fulli_exists
@@ -900,7 +1029,7 @@ module SensibleSwing
900
1029
  EOL
901
1030
  if !fulli_dot_done_file_exists? save_to
902
1031
  popup_message += "This could take quite awhile (several hours), and will prompt you with a chime noise when it is done.\n
903
- You can close this window and minimize sensible cinema and continue using your computer while it runs in the background."
1032
+ You can close this window and minimize sensible cinema and continue using your computer while it runs in the background.\n"
904
1033
  end
905
1034
 
906
1035
  if !start_time
@@ -915,7 +1044,7 @@ module SensibleSwing
915
1044
 
916
1045
  # allow our popups to still be serviced while it is running
917
1046
  @background_thread = Thread.new {
918
- run_create_commands commands, save_to, run_mplayer
1047
+ run_batch_file_commands commands, save_to, file_from, run_mplayer
919
1048
  popup.dispose
920
1049
  }
921
1050
  # LODO warn if they will overwrite a file in the end...
@@ -923,7 +1052,7 @@ module SensibleSwing
923
1052
 
924
1053
  attr_accessor :background_thread, :buttons
925
1054
 
926
- def run_create_commands batch_commands, save_to, run_mplayer
1055
+ def run_batch_file_commands batch_commands, save_to, file_from, run_mplayer_after_done
927
1056
  @buttons.each{|b| b.set_enabled false}
928
1057
  success = true
929
1058
  lines = batch_commands.lines.to_a
@@ -944,37 +1073,49 @@ module SensibleSwing
944
1073
  @buttons.each{|b| b.set_enabled true}
945
1074
  if success
946
1075
  saved_to = save_to + '.avi'
947
- if run_mplayer
948
- set_smplayer_opts ''
949
- system_non_blocking "smplayer_portable #{saved_to}"
1076
+ if run_mplayer_after_done
1077
+ Thread.new { run_smplayer_blocking saved_to, '', false}
950
1078
  else
951
- show_file = "explorer /e,/select,\"#{File.expand_path(saved_to).to_filename}\""
952
- begin
953
- system_blocking show_file # returns immediately tho...
954
- rescue => why_does_this_happen_ignore_this_exception_it_actually_succeeded
955
- end
1079
+ if File.exist?(saved_to) && (File.size(saved_to).to_f/File.size(file_from) < 0.5) # less than 50% size is suspicious...indeed...check if exists for unit tests.
1080
+ show_blocking_message_dialog("Warning: file size differs by more than 50%--it's possible that transcoding failed somehow")
1081
+ end
1082
+ show_in_explorer saved_to
956
1083
  PlayAudio.play(File.expand_path(File.dirname(__FILE__)) + "/../vendor/music.wav")
957
- show_blocking_message_dialog "Done--you may now watch file\n #{saved_to}\n in VLC player (or possibly smplayer)"
1084
+ msg = "Done--you may now watch file\n #{saved_to}\n in VLC player (or possibly smplayer)"
1085
+ puts msg
1086
+ show_blocking_message_dialog msg
1087
+ show_in_explorer saved_to # and again :)
958
1088
  end
959
1089
  else
960
1090
  show_blocking_message_dialog("Failed--please examine console output and report back!\nAlso consult the documentation/troubleshooting file.", "Failed", JOptionPane::ERROR_MESSAGE)
961
1091
  end
962
1092
  end
963
1093
 
1094
+ def show_in_explorer filename
1095
+ begin
1096
+ system_blocking "explorer /e,/select,\"#{File.expand_path(filename).to_filename}\"" # command returns immediately...
1097
+ rescue => why_does_this_happen_ignore_this_exception_it_probably_actually_succeeded
1098
+ end
1099
+ end
1100
+
964
1101
  def get_disk_chooser_window names
965
1102
  GetDisk.new(self, names)
966
1103
  end
967
1104
 
968
- NonDvd = 'non dvd has no dvdid'
1105
+ NonDvd = 'non dvd has no dvdid' # we need it for convenience, say you want to go through your indexed vids and convert them all?
969
1106
 
970
1107
  # returns e:\, volume_name, dvd_id
971
1108
  # or full_path.mkv, filename, ''
972
1109
  def choose_dvd_drive_or_file force_choose_only_dvd_drive
973
1110
  opticals = DriveInfo.get_dvd_drives_as_openstruct
974
- if @saved_opticals == opticals
1111
+ if @saved_opticals == opticals && @_choose_dvd_drive_or_file
975
1112
  # memoize...if disks haven't changed :)
976
1113
  return @_choose_dvd_drive_or_file
1114
+ else
1115
+ @saved_opticals = opticals # save currently mounted disk list, so we know if we should re-select later...
1116
+ # is this ok for os x?
977
1117
  end
1118
+
978
1119
  has_at_least_one_dvd_inserted = opticals.find{|d| d.VolumeName }
979
1120
  if !has_at_least_one_dvd_inserted && force_choose_only_dvd_drive
980
1121
  show_blocking_message_dialog 'insert a dvd first'
@@ -982,16 +1123,21 @@ module SensibleSwing
982
1123
  end
983
1124
  names = opticals.map{|d| d.Name + "\\" + " (" + (d.VolumeName || 'Insert DVD to use') + ")"}
984
1125
  if !force_choose_only_dvd_drive && !has_at_least_one_dvd_inserted
985
- names += ['No DVD so choose Local File']
1126
+ names += ['No DVD mounted so choose Local File (or insert DVD, re-try)']
986
1127
  used_local_file_option = true
987
1128
  end
988
1129
 
989
1130
  count = 0
990
1131
  opticals.each{|d| count += 1 if d.VolumeName}
991
- if count == 1 && force_choose_only_dvd_drive
1132
+ if count == 1 && !used_local_file_option
992
1133
  # just choose it if there's only one disk available..
993
1134
  p 'selecting only disk present in the various DVD drives'
994
1135
  selected_idx = opticals.index{|d| d.VolumeName}
1136
+ unless selected_idx
1137
+ show_blocking_message_dialog "Please insert a disk first"
1138
+ raise 'inset disk'
1139
+ end
1140
+
995
1141
  else
996
1142
  dialog = get_disk_chooser_window names
997
1143
  dialog.setSize 200, 125
@@ -1007,11 +1153,11 @@ module SensibleSwing
1007
1153
  @_choose_dvd_drive_or_file = [filename, File.basename(filename), NonDvd]
1008
1154
  else
1009
1155
  disk = opticals[selected_idx]
1156
+ out = show_non_blocking_message_dialog "calculating disk's unique id..." # useful, believe it or not
1010
1157
  dvd_id = DriveInfo.md5sum_disk(disk.MountPoint)
1158
+ out.dispose
1011
1159
  @_choose_dvd_drive_or_file = [disk.MountPoint, opticals[selected_idx].VolumeName, dvd_id]
1012
1160
  end
1013
- @saved_opticals = opticals # save currently mounted disk list, so we know if we should re-select later...
1014
- # is this ok for os x?
1015
1161
  return @_choose_dvd_drive_or_file
1016
1162
  else
1017
1163
  raise 'did not select a drive...'
@@ -1045,35 +1191,6 @@ module SensibleSwing
1045
1191
  end
1046
1192
  end
1047
1193
 
1048
- class ShutdownHook
1049
- include java.lang.Runnable
1050
- def initialize( &block)
1051
- super()
1052
- @block=block
1053
- end
1054
- def run
1055
- @block[]
1056
- end
1057
- end
1058
-
1059
- def at_exit2( &block)
1060
- hook = ShutdownHook.new( &block)
1061
- java.lang.Runtime.getRuntime.addShutdownHook(java.lang.Thread.new( hook ))
1062
- end
1063
-
1064
- def kill_processes
1065
- if OS.windows?
1066
- system_original("taskkill /f /im mencoder.exe 2>NUL") # todo...is there a better way?
1067
- system_original("taskkill /f /im ffmpeg.exe 2>NUL")
1068
- system_original("taskkill /f /im smplayer_portable.exe 2>NUL")
1069
- system_original("taskkill /f /im mplayer.exe 2>NUL")
1070
- end
1071
- end
1072
-
1073
- at_exit2 {
1074
- kill_processes # just in case
1075
- }
1076
-
1077
1194
  if $0 == __FILE__
1078
1195
  if ARGV.index('-h') || ARGV.index('--help')
1079
1196
  puts 'syntax: [--create-mode]'