- Timestamp:
- 04/18/06 15:27:19 (6 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 12 edited
-
Makefile.am (modified) (3 diffs)
-
org/thestaticvoid/iriverter/Converter.java (modified) (10 diffs)
-
org/thestaticvoid/iriverter/ConverterOptions.java (modified) (14 diffs)
-
org/thestaticvoid/iriverter/ConverterUI.java (modified) (20 diffs)
-
org/thestaticvoid/iriverter/DVD.java (modified) (4 diffs)
-
org/thestaticvoid/iriverter/Directory.java (modified) (5 diffs)
-
org/thestaticvoid/iriverter/JoinVideos.java (modified) (2 diffs)
-
org/thestaticvoid/iriverter/LogViewer.java (modified) (4 diffs)
-
org/thestaticvoid/iriverter/Logger.java (modified) (4 diffs)
-
org/thestaticvoid/iriverter/MPlayerInfo.java (modified) (2 diffs)
-
org/thestaticvoid/iriverter/ManualSplit.java (modified) (2 diffs)
-
org/thestaticvoid/iriverter/SingleVideo.java (modified) (4 diffs)
-
org/thestaticvoid/iriverter/icons/save-24.png (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Makefile.am
r94 r102 15 15 iriverter_source_files = \ 16 16 org/thestaticvoid/iriverter/Logger.java \ 17 org/thestaticvoid/iriverter/LogViewer.java \ 17 18 org/thestaticvoid/iriverter/DVD.java \ 18 19 org/thestaticvoid/iriverter/SingleVideoAdapter.java \ … … 71 72 org/thestaticvoid/iriverter/icons/home-24.png \ 72 73 org/thestaticvoid/iriverter/icons/forward-24.png \ 73 org/thestaticvoid/iriverter/icons/singlevideo-16.png 74 org/thestaticvoid/iriverter/icons/singlevideo-16.png \ 75 org/thestaticvoid/iriverter/icons/save-24.png 74 76 75 77 iriverter_resources = \ … … 116 118 $(iriverter_source_files) \ 117 119 $(iriverter_icons) \ 120 $(iriverter_resources) \ 118 121 iriverter.desktop \ 119 122 iriverter.ico \ -
trunk/src/org/thestaticvoid/iriverter/Converter.java
r97 r102 7 7 private List jobs, notSplitVideos; 8 8 private ProgressDialogInfo progressDialogInfo; 9 private ConverterOptions converterOptions;10 9 private Process proc; 11 10 private boolean isCanceled; 12 11 private int exitCode; 13 12 14 public Converter(List jobs, ProgressDialogInfo progressDialogInfo , ConverterOptions converterOptions) {15 this.jobs = Converter.checkForOverwritingFiles(Converter.expandSingleJobsToMultiple(Converter.removeInvalidJobs(jobs , converterOptions), converterOptions));13 public Converter(List jobs, ProgressDialogInfo progressDialogInfo) { 14 this.jobs = Converter.checkForOverwritingFiles(Converter.expandSingleJobsToMultiple(Converter.removeInvalidJobs(jobs))); 16 15 this.progressDialogInfo = progressDialogInfo; 17 this.converterOptions = converterOptions;18 16 isCanceled = false; 19 17 … … 23 21 } 24 22 25 public static List removeInvalidJobs(List jobs , ConverterOptions converterOptions) {23 public static List removeInvalidJobs(List jobs) { 26 24 List newJobs = new ArrayList(); 27 25 … … 34 32 continue; 35 33 36 if (!outputVideoInfo.getOutputVideo().endsWith("." + converterOptions.getCurrentProfile().getWrapperFormat()) && !outputVideoInfo.getOutputVideo().equals(""))37 outputVideoInfo.setOutputVideo(outputVideoInfo.getOutputVideo() + "." + converterOptions.getCurrentProfile().getWrapperFormat());34 if (!outputVideoInfo.getOutputVideo().endsWith("." + ConverterOptions.getCurrentProfile().getWrapperFormat()) && !outputVideoInfo.getOutputVideo().equals("")) 35 outputVideoInfo.setOutputVideo(outputVideoInfo.getOutputVideo() + "." + ConverterOptions.getCurrentProfile().getWrapperFormat()); 38 36 39 37 if (!new File(outputVideoInfo.getOutputVideo()).getParentFile().exists()) … … 73 71 } 74 72 75 public static List expandSingleJobsToMultiple(List jobs , ConverterOptions converterOptions) {73 public static List expandSingleJobsToMultiple(List jobs) { 76 74 List newJobs = new ArrayList(); 77 75 78 76 for (int i = 0; i < jobs.size(); i++) 79 77 if (jobs.get(i) instanceof DirectoryInfo) 80 newJobs.addAll(convertDirectoryToSingleVideos((DirectoryInfo) jobs.get(i) , converterOptions));78 newJobs.addAll(convertDirectoryToSingleVideos((DirectoryInfo) jobs.get(i))); 81 79 else if (jobs.get(i) instanceof DVDInfo) 82 80 newJobs.addAll(separateDVDChaptersToSingleDVDJobs((DVDInfo) jobs.get(i))); … … 89 87 } 90 88 91 public static List convertDirectoryToSingleVideos(DirectoryInfo directoryInfo , ConverterOptions converterOptions) {89 public static List convertDirectoryToSingleVideos(DirectoryInfo directoryInfo) { 92 90 List newJobs = new ArrayList(); 93 91 … … 96 94 for (int i = 0; i < directory.length; i++) 97 95 if (new File(directoryInfo.getInputDirectory() + File.separator + directory[i]).isDirectory() && directoryInfo.getConvertSubdirectories()) 98 newJobs.addAll(convertDirectoryToSingleVideos(new DirectoryAdapter(directoryInfo.getInputDirectory() + File.separator + directory[i], directoryInfo.getOutputDirectory() + File.separator + directory[i], directoryInfo.getConvertSubdirectories()) , converterOptions));96 newJobs.addAll(convertDirectoryToSingleVideos(new DirectoryAdapter(directoryInfo.getInputDirectory() + File.separator + directory[i], directoryInfo.getOutputDirectory() + File.separator + directory[i], directoryInfo.getConvertSubdirectories()))); 99 97 else if (new File(directoryInfo.getInputDirectory() + File.separator + directory[i]).isFile()) 100 newJobs.add(new SingleVideoAdapter(directoryInfo.getInputDirectory() + File.separator + directory[i], directoryInfo.getOutputDirectory() + File.separator + directory[i].substring(0, directory[i].lastIndexOf('.')) + "." + converterOptions.getCurrentProfile().getProfileName() + ".avi"));98 newJobs.add(new SingleVideoAdapter(directoryInfo.getInputDirectory() + File.separator + directory[i], directoryInfo.getOutputDirectory() + File.separator + directory[i].substring(0, directory[i].lastIndexOf('.')) + "." + ConverterOptions.getCurrentProfile().getProfileName() + ".avi")); 101 99 102 100 return newJobs; … … 183 181 commandList.add(outputVideo); 184 182 185 if ( converterOptions.getCurrentProfile().getWrapperFormat().equals("mp4")) {183 if (ConverterOptions.getCurrentProfile().getWrapperFormat().equals("mp4")) { 186 184 commandList.add("-of"); 187 185 commandList.add("lavf"); … … 191 189 192 190 commandList.add("-ovc"); 193 if ( converterOptions.getCurrentProfile().getVideoFormat().equals("h264")) {191 if (ConverterOptions.getCurrentProfile().getVideoFormat().equals("h264")) { 194 192 commandList.add("x264"); 195 193 commandList.add("-x264encopts"); 196 commandList.add("bitrate=" + converterOptions.getVideoBitrate() + ":bframes=0:level_idc=13:nocabac");194 commandList.add("bitrate=" + ConverterOptions.getVideoBitrate() + ":bframes=0:level_idc=13:nocabac"); 197 195 } else { 198 196 commandList.add("xvid"); 199 197 commandList.add("-xvidencopts"); 200 commandList.add("bitrate=" + converterOptions.getVideoBitrate() + ":max_bframes=0");198 commandList.add("bitrate=" + ConverterOptions.getVideoBitrate() + ":max_bframes=0"); 201 199 } 202 200 203 201 commandList.add("-oac"); 204 if ( converterOptions.getCurrentProfile().getAudioFormat().equals("aac")) {202 if (ConverterOptions.getCurrentProfile().getAudioFormat().equals("aac")) { 205 203 commandList.add("faac"); 206 204 commandList.add("-faacopts"); 207 commandList.add("br=" + converterOptions.getAudioBitrate() + ":object=1");205 commandList.add("br=" + ConverterOptions.getAudioBitrate() + ":object=1"); 208 206 } else { 209 207 commandList.add("mp3lame"); 210 208 commandList.add("-lameopts"); 211 commandList.add("mode=2:cbr:br=" + converterOptions.getAudioBitrate());212 } 213 214 double ofps = (info.getFrameRate() > converterOptions.getCurrentProfile().getMaxFrameRate() ? converterOptions.getCurrentProfile().getMaxFrameRate() : info.getFrameRate());209 commandList.add("mode=2:cbr:br=" + ConverterOptions.getAudioBitrate()); 210 } 211 212 double ofps = (info.getFrameRate() > ConverterOptions.getCurrentProfile().getMaxFrameRate() ? ConverterOptions.getCurrentProfile().getMaxFrameRate() : info.getFrameRate()); 215 213 commandList.add("-vf"); 216 214 commandList.add("filmdint=io=" + ((int) Math.round(info.getFrameRate() * 1000)) + ":" + ((int) Math.round(ofps * 1000))); 217 215 218 int scaledWidth = converterOptions.getDimensions().getWidth();219 int scaledHeight = (info.getDimensions().getHeight() * converterOptions.getDimensions().getWidth()) / info.getDimensions().getWidth();220 221 if (scaledHeight > converterOptions.getDimensions().getHeight()) {222 scaledWidth = (scaledWidth * converterOptions.getDimensions().getHeight()) / scaledHeight;223 scaledHeight = converterOptions.getDimensions().getHeight();216 int scaledWidth = ConverterOptions.getDimensions().getWidth(); 217 int scaledHeight = (info.getDimensions().getHeight() * ConverterOptions.getDimensions().getWidth()) / info.getDimensions().getWidth(); 218 219 if (scaledHeight > ConverterOptions.getDimensions().getHeight()) { 220 scaledWidth = (scaledWidth * ConverterOptions.getDimensions().getHeight()) / scaledHeight; 221 scaledHeight = ConverterOptions.getDimensions().getHeight(); 224 222 } 225 223 226 224 commandList.add("-vf-add"); 227 if ( converterOptions.getPanAndScan())228 commandList.add("scale=" + ((int) ((info.getDimensions().getWidth()) * (((double) converterOptions.getDimensions().getHeight()) / (double) info.getDimensions().getHeight()))) + ":" + converterOptions.getDimensions().getHeight() + ",crop=" + converterOptions.getDimensions().getWidth() + ":" + converterOptions.getDimensions().getHeight());225 if (ConverterOptions.getPanAndScan()) 226 commandList.add("scale=" + ((int) ((info.getDimensions().getWidth()) * (((double) ConverterOptions.getDimensions().getHeight()) / (double) info.getDimensions().getHeight()))) + ":" + ConverterOptions.getDimensions().getHeight() + ",crop=" + ConverterOptions.getDimensions().getWidth() + ":" + ConverterOptions.getDimensions().getHeight()); 229 227 else 230 commandList.add("scale=" + scaledWidth + ":" + scaledHeight + ",expand=" + converterOptions.getDimensions().getWidth() + ":" + converterOptions.getDimensions().getHeight());228 commandList.add("scale=" + scaledWidth + ":" + scaledHeight + ",expand=" + ConverterOptions.getDimensions().getWidth() + ":" + ConverterOptions.getDimensions().getHeight()); 231 229 232 230 commandList.add("-vf-add"); 233 231 commandList.add("harddup"); 234 232 235 if ( converterOptions.getVolumeFilter() == VolumeFilter.VOLNORM) {233 if (ConverterOptions.getVolumeFilter() == VolumeFilter.VOLNORM) { 236 234 commandList.add("-af"); 237 235 commandList.add("volnorm"); 238 } else if ( converterOptions.getVolumeFilter() == VolumeFilter.VOLUME) {236 } else if (ConverterOptions.getVolumeFilter() == VolumeFilter.VOLUME) { 239 237 commandList.add("-af"); 240 commandList.add("volume=" + converterOptions.getGain());238 commandList.add("volume=" + ConverterOptions.getGain()); 241 239 } 242 240 … … 246 244 commandList.add("44100"); 247 245 248 if (! converterOptions.getAutoSync()) {246 if (!ConverterOptions.getAutoSync()) { 249 247 commandList.add("-delay"); 250 commandList.add("" + ( converterOptions.getAudioDelay() / 1000.0));248 commandList.add("" + (ConverterOptions.getAudioDelay() / 1000.0)); 251 249 } 252 250 … … 427 425 428 426 public void splitVideo(String inputVideo, int length) { 429 if (length < converterOptions.getSplitTime() * 60)427 if (length < ConverterOptions.getSplitTime() * 60) 430 428 return; 431 429 432 if (! converterOptions.getAutoSplit()) {430 if (!ConverterOptions.getAutoSplit()) { 433 431 notSplitVideos.add(inputVideo); 434 432 return; 435 433 } 436 434 437 int pieces = (length / ( converterOptions.getSplitTime() * 60)) + 1;435 int pieces = (length / (ConverterOptions.getSplitTime() * 60)) + 1; 438 436 for (int i = 0; i < pieces; i++) { 439 437 String outputVideo = inputVideo.substring(0, inputVideo.lastIndexOf('.')) + ".part" + (i + 1) + ".avi"; -
trunk/src/org/thestaticvoid/iriverter/ConverterOptions.java
r81 r102 4 4 5 5 public class ConverterOptions { 6 private File optionsFile; 7 8 public ConverterOptions(File optionsFile) { 9 this.optionsFile = optionsFile; 6 private static File optionsFile = new File(System.getProperty("user.home") + File.separator + ".iriverter.conf"); 7 8 public static String getOptionsText() { 9 BufferedReader input = null; 10 try { 11 input = new BufferedReader(new FileReader(optionsFile)); 12 } catch (IOException e) { 13 // empty 14 } 15 16 String text = ""; 17 if (input != null) { 18 try { 19 String line; 20 while ((line = input.readLine()) != null) 21 text += line + "\n"; 22 } catch (IOException e) { 23 e.printStackTrace(); 24 } 25 } 26 27 return text; 10 28 } 11 29 12 public void writeOption(String option, String setting) {30 public static void writeOption(String option, String setting) { 13 31 try { 32 Logger.logMessage("Setting: " + option + "=" + setting, Logger.INFO); 33 14 34 if (!optionsFile.exists()) 15 35 optionsFile.createNewFile(); … … 42 62 } 43 63 44 public String readOption(String option) {64 public static String readOption(String option) { 45 65 String returnSetting = ""; 46 66 … … 61 81 } 62 82 63 public void setCurrentProfile(Profile profile) {83 public static void setCurrentProfile(Profile profile) { 64 84 writeOption("currentProfile", profile.getProfileName()); 65 85 writeOption("videoBitrate", ""); … … 71 91 } 72 92 73 public Profile getCurrentProfile() {93 public static Profile getCurrentProfile() { 74 94 String currentProfile = readOption("currentProfile"); 75 95 if (currentProfile.equals("")) … … 79 99 } 80 100 81 public boolean getPanAndScan() {101 public static boolean getPanAndScan() { 82 102 String panAndScan = readOption("panAndScan"); 83 103 if (panAndScan.equals("")) … … 87 107 } 88 108 89 public int getVideoBitrate() {109 public static int getVideoBitrate() { 90 110 String videoBitrate = readOption("videoBitrate"); 91 111 if (videoBitrate.equals("")) … … 95 115 } 96 116 97 public int getAudioBitrate() {117 public static int getAudioBitrate() { 98 118 String audioBitrate = readOption("audioBitrate"); 99 119 if (audioBitrate.equals("")) … … 103 123 } 104 124 105 public Dimensions getDimensions() {125 public static Dimensions getDimensions() { 106 126 String dimensions = readOption("dimensions"); 107 127 if (dimensions.equals("")) … … 111 131 } 112 132 113 public boolean getAutoSync() {133 public static boolean getAutoSync() { 114 134 String autoSync = readOption("autoSync"); 115 135 if (autoSync.equals("")) … … 119 139 } 120 140 121 public int getAudioDelay() {141 public static int getAudioDelay() { 122 142 String audioDelay = readOption("audioDelay"); 123 143 if (audioDelay.equals("")) … … 127 147 } 128 148 129 public boolean getAutoSplit() {149 public static boolean getAutoSplit() { 130 150 String autoSplit = readOption("autoSplit"); 131 151 if (autoSplit.equals("")) … … 135 155 } 136 156 137 public int getSplitTime() {157 public static int getSplitTime() { 138 158 String splitTime = readOption("splitTime"); 139 159 if (splitTime.equals("")) … … 143 163 } 144 164 145 public int getVolumeFilter() {165 public static int getVolumeFilter() { 146 166 String volumeFilter = readOption("volumeFilter"); 147 167 if (volumeFilter.equals("") || volumeFilter.equals("none")) … … 153 173 } 154 174 155 public double getGain() {175 public static double getGain() { 156 176 String gain = readOption("gain"); 157 177 if (gain.equals("")) -
trunk/src/org/thestaticvoid/iriverter/ConverterUI.java
r98 r102 13 13 14 14 public class ConverterUI implements SelectionListener, CTabFolder2Listener, DropTargetListener { 15 private ConverterOptions converterOptions;16 15 private Display display; 17 16 private Shell shell; … … 26 25 private ProgressDialog progressDialog; 27 26 28 public ConverterUI() { 29 converterOptions = new ConverterOptions(new File(System.getProperty("user.home") + File.separator + ".iriverter.conf")); 30 27 public ConverterUI() { 31 28 display = new Display(); 32 29 … … 112 109 advancedJobs.setText("&Advanced"); 113 110 114 advancedJobs.setEnabled( converterOptions.getCurrentProfile().getWrapperFormat().equals("avi"));111 advancedJobs.setEnabled(ConverterOptions.getCurrentProfile().getWrapperFormat().equals("avi")); 115 112 116 113 Menu advancedJobsMenu = new Menu(shell, SWT.DROP_DOWN); … … 172 169 profileMenuItems = new HashMap(); 173 170 Profile[] profiles = Profile.getAllProfiles(); 174 Profile currentProfile = converterOptions.getCurrentProfile();171 Profile currentProfile = ConverterOptions.getCurrentProfile(); 175 172 176 173 Map deviceToProfile = new HashMap(); … … 231 228 panAndScan.setText("&Pan and Scan\tShift+Ctrl+P"); 232 229 panAndScan.setAccelerator(SWT.SHIFT + SWT.CTRL + 'P'); 233 panAndScan.setSelection( converterOptions.getPanAndScan());230 panAndScan.setSelection(ConverterOptions.getPanAndScan()); 234 231 panAndScan.addSelectionListener(this); 235 232 … … 248 245 automaticallySplit.addSelectionListener(this); 249 246 250 automaticallySplit.setEnabled( converterOptions.getCurrentProfile().getWrapperFormat().equals("avi"));247 automaticallySplit.setEnabled(ConverterOptions.getCurrentProfile().getWrapperFormat().equals("avi")); 251 248 252 249 volume = new MenuItem(advancedOptionsMenu, SWT.PUSH); … … 309 306 newDVDTool.addSelectionListener(this); 310 307 } 311 308 312 309 public void widgetDefaultSelected(SelectionEvent e) { 313 310 // empty … … 324 321 325 322 progressDialog = new ProgressDialog(shell, SWT.NONE); 326 Converter converter = new Converter(jobs, progressDialog , converterOptions);323 Converter converter = new Converter(jobs, progressDialog); 327 324 converter.start(); 328 325 progressDialog.open(); … … 415 412 String selectedProfileName = (String) profileMenuItems.get(selectedMenuItem); 416 413 417 if (selectedProfileName.equals( converterOptions.getCurrentProfile().getProfileName()))414 if (selectedProfileName.equals(ConverterOptions.getCurrentProfile().getProfileName())) 418 415 return; 419 416 … … 422 419 selectedMenuItem.setSelection(true); 423 420 424 converterOptions.setCurrentProfile(Profile.getProfile(selectedProfileName));421 ConverterOptions.setCurrentProfile(Profile.getProfile(selectedProfileName)); 425 422 profileChanged(); 426 423 } 427 424 428 425 if (e.getSource() == bitrate) { 429 BitrateDialog bitrateDialog = new BitrateDialog(shell, SWT.NONE, new Bitrate( converterOptions.getCurrentProfile().getMaxVideoBitrate(), converterOptions.getCurrentProfile().getMaxAudioBitrate()), new Bitrate(converterOptions.getVideoBitrate(), converterOptions.getAudioBitrate()));426 BitrateDialog bitrateDialog = new BitrateDialog(shell, SWT.NONE, new Bitrate(ConverterOptions.getCurrentProfile().getMaxVideoBitrate(), ConverterOptions.getCurrentProfile().getMaxAudioBitrate()), new Bitrate(ConverterOptions.getVideoBitrate(), ConverterOptions.getAudioBitrate())); 430 427 Bitrate newBitrate = bitrateDialog.open(); 431 converterOptions.writeOption("videoBitrate", "" + newBitrate.getVideo());432 converterOptions.writeOption("audioBitrate", "" + newBitrate.getAudio());428 ConverterOptions.writeOption("videoBitrate", "" + newBitrate.getVideo()); 429 ConverterOptions.writeOption("audioBitrate", "" + newBitrate.getAudio()); 433 430 } 434 431 … … 438 435 439 436 if (e.getSource() == panAndScan) 440 converterOptions.writeOption("panAndScan", "" + panAndScan.getSelection());437 ConverterOptions.writeOption("panAndScan", "" + panAndScan.getSelection()); 441 438 442 439 if (e.getSource() == audioSync) { 443 int audioDelay = new AudioSyncDialog(shell, SWT.NONE, ( converterOptions.getAutoSync()) ? AudioSyncDialog.AUTO_SYNC : converterOptions.getAudioDelay()).open();440 int audioDelay = new AudioSyncDialog(shell, SWT.NONE, (ConverterOptions.getAutoSync()) ? AudioSyncDialog.AUTO_SYNC : ConverterOptions.getAudioDelay()).open(); 444 441 445 442 if (audioDelay == AudioSyncDialog.AUTO_SYNC) { 446 converterOptions.writeOption("autoSync", "true");447 converterOptions.writeOption("audioDelay", "0");443 ConverterOptions.writeOption("autoSync", "true"); 444 ConverterOptions.writeOption("audioDelay", "0"); 448 445 } else { 449 converterOptions.writeOption("autoSync", "false");450 converterOptions.writeOption("audioDelay", "" + audioDelay);446 ConverterOptions.writeOption("autoSync", "false"); 447 ConverterOptions.writeOption("audioDelay", "" + audioDelay); 451 448 } 452 449 } 453 450 454 451 if (e.getSource() == automaticallySplit) { 455 int splitTime = new AutomaticallySplitDialog(shell, SWT.NONE, converterOptions.getAutoSplit(), converterOptions.getSplitTime()).open();452 int splitTime = new AutomaticallySplitDialog(shell, SWT.NONE, ConverterOptions.getAutoSplit(), ConverterOptions.getSplitTime()).open(); 456 453 457 454 if (splitTime == AutomaticallySplitDialog.NO_SPLIT) 458 converterOptions.writeOption("autoSplit", "false");455 ConverterOptions.writeOption("autoSplit", "false"); 459 456 else { 460 converterOptions.writeOption("autoSplit", "true");461 converterOptions.writeOption("splitTime", "" + splitTime);457 ConverterOptions.writeOption("autoSplit", "true"); 458 ConverterOptions.writeOption("splitTime", "" + splitTime); 462 459 } 463 460 } 464 461 465 462 if (e.getSource() == volume) { 466 double volume = new VolumeDialog(shell, SWT.NONE, converterOptions.getVolumeFilter(), converterOptions.getGain()).open();463 double volume = new VolumeDialog(shell, SWT.NONE, ConverterOptions.getVolumeFilter(), ConverterOptions.getGain()).open(); 467 464 468 465 if (volume == VolumeDialog.NONE) 469 converterOptions.writeOption("volumeFilter", "none");466 ConverterOptions.writeOption("volumeFilter", "none"); 470 467 else if (volume == VolumeDialog.VOLNORM) 471 converterOptions.writeOption("volumeFilter", "volnorm");468 ConverterOptions.writeOption("volumeFilter", "volnorm"); 472 469 else { 473 converterOptions.writeOption("volumeFilter", "volume");474 converterOptions.writeOption("gain", "" + volume);470 ConverterOptions.writeOption("volumeFilter", "volume"); 471 ConverterOptions.writeOption("gain", "" + volume); 475 472 } 476 473 } … … 503 500 dimensionsMenuItems.clear(); 504 501 505 Dimensions[] dimensions = converterOptions.getCurrentProfile().getDimensions();506 Dimensions currentDimensions = converterOptions.getDimensions();502 Dimensions[] dimensions = ConverterOptions.getCurrentProfile().getDimensions(); 503 Dimensions currentDimensions = ConverterOptions.getDimensions(); 507 504 508 505 for (int i = 0; i < dimensions.length; i++) { … … 515 512 } 516 513 517 advancedJobs.setEnabled( converterOptions.getCurrentProfile().getWrapperFormat().equals("avi"));518 automaticallySplit.setEnabled( converterOptions.getCurrentProfile().getWrapperFormat().equals("avi"));514 advancedJobs.setEnabled(ConverterOptions.getCurrentProfile().getWrapperFormat().equals("avi")); 515 automaticallySplit.setEnabled(ConverterOptions.getCurrentProfile().getWrapperFormat().equals("avi")); 519 516 } 520 517 … … 606 603 private SingleVideo newSingleVideo() { 607 604 CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE); 608 SingleVideo singleVideo = new SingleVideo(tabFolder, SWT.NONE, tabItem , converterOptions);605 SingleVideo singleVideo = new SingleVideo(tabFolder, SWT.NONE, tabItem); 609 606 tabItem.setControl(singleVideo); 610 607 tabFolder.setSelection(tabItem); … … 616 613 private Directory newDirectory() { 617 614 CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE); 618 Directory directory = new Directory(tabFolder, SWT.NONE, tabItem , converterOptions);615 Directory directory = new Directory(tabFolder, SWT.NONE, tabItem); 619 616 tabItem.setControl(directory); 620 617 tabFolder.setSelection(tabItem); … … 631 628 632 629 CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE); 633 DVD dvd = new DVD(tabFolder, SWT.NONE, tabItem , converterOptions);630 DVD dvd = new DVD(tabFolder, SWT.NONE, tabItem); 634 631 tabItem.setControl(dvd); 635 632 tabFolder.setSelection(tabItem); … … 647 644 private ManualSplit newManualSplit() { 648 645 CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE); 649 ManualSplit manualSplit = new ManualSplit(tabFolder, SWT.NONE, tabItem , converterOptions);646 ManualSplit manualSplit = new ManualSplit(tabFolder, SWT.NONE, tabItem); 650 647 tabItem.setControl(manualSplit); 651 648 tabFolder.setSelection(tabItem); … … 657 654 private JoinVideos newJoinVideos() { 658 655 CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE); 659 JoinVideos joinVideos = new JoinVideos(tabFolder, SWT.NONE, tabItem , converterOptions);656 JoinVideos joinVideos = new JoinVideos(tabFolder, SWT.NONE, tabItem); 660 657 tabItem.setControl(joinVideos); 661 658 tabFolder.setSelection(tabItem); … … 667 664 public static void main(String[] args) { 668 665 try { 669 ConverterUI ui =new ConverterUI();666 new ConverterUI(); 670 667 } catch (Throwable t) { 671 String message = "An unhandled exception occured: " + t.get Message() + "\n\n";668 String message = "An unhandled exception occured: " + t.getClass() + "\n" + t.getMessage() + "\n\n"; 672 669 StackTraceElement[] st = t.getStackTrace(); 673 670 for (int i = 0; i < st.length; i++) … … 678 675 MessageBox messageBox = new MessageBox(new Shell(Display.getDefault()), SWT.ICON_ERROR | SWT.OK); 679 676 messageBox.setText("Error"); 680 messageBox.setMessage("An unhandled exception occured. Please see the log for details.");677 messageBox.setMessage("An unhandled exception occured. The program will close. Please see the log for details."); 681 678 messageBox.open(); 682 679 } -
trunk/src/org/thestaticvoid/iriverter/DVD.java
r88 r102 13 13 public class DVD extends Composite implements SelectionListener, TabItemControl, DVDInfo { 14 14 private CTabItem tabItem; 15 private ConverterOptions converterOptions;16 15 private Combo dvdCombo, titleCombo, audioStreamCombo, subtitlesCombo; 17 16 private Map titleInfo, audioStreams, subtitles; … … 24 23 private Process proc; 25 24 26 public DVD(Composite parent, int style, CTabItem tabItem , ConverterOptions converterOptions) {25 public DVD(Composite parent, int style, CTabItem tabItem) { 27 26 super(parent, style); 28 27 this.tabItem = tabItem; 29 this.converterOptions = converterOptions;30 28 31 29 titleInfo = new LinkedHashMap(); … … 214 212 } 215 213 214 String commandStr = ""; 216 215 String[] command = new String[commandList.size()]; 217 for (int i = 0; i < command.length; i++) 216 for (int i = 0; i < command.length; i++) { 218 217 command[i] = (String) commandList.get(i); 218 commandStr += command[i] + " "; 219 } 220 Logger.logMessage(commandStr, Logger.INFO); 219 221 220 222 proc = Runtime.getRuntime().exec(command); … … 228 230 FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE); 229 231 fileDialog.setText("Output Video"); 230 if ( converterOptions.getCurrentProfile().getWrapperFormat().equals("mp4")) {232 if (ConverterOptions.getCurrentProfile().getWrapperFormat().equals("mp4")) { 231 233 fileDialog.setFilterExtensions(new String[]{"*.mp4"}); 232 234 fileDialog.setFilterNames(new String[]{"MP4 Video (*.mp4)"}); -
trunk/src/org/thestaticvoid/iriverter/Directory.java
r32 r102 12 12 public class Directory extends Composite implements SelectionListener, TabItemControl, DirectoryInfo { 13 13 private CTabItem tabItem; 14 private ConverterOptions converterOptions;15 14 private Text inputDirectoryInput, outputDirectoryInput; 16 15 private Button inputDirectorySelect, outputDirectorySelect, convertSubdirectories; … … 18 17 private boolean syncConvertSubdirectories; 19 18 20 public Directory(Composite parent, int style, CTabItem tabItem , ConverterOptions converterOptions) {19 public Directory(Composite parent, int style, CTabItem tabItem) { 21 20 super(parent, style); 22 21 this.tabItem = tabItem; 23 this.converterOptions = converterOptions;24 22 25 23 InputStream is = getClass().getResourceAsStream("icons/directory-16.png"); … … 81 79 tab.setText("\t"); */ 82 80 83 Label emptyLabel =new Label(this, SWT.NONE);81 new Label(this, SWT.NONE); 84 82 85 83 convertSubdirectories = new Button(this, SWT.CHECK); … … 101 99 if (directory != null) { 102 100 inputDirectoryInput.setText(directory); 103 outputDirectoryInput.setText(directory + "-" + converterOptions.getCurrentProfile().getProfileName());101 outputDirectoryInput.setText(directory + "-" + ConverterOptions.getCurrentProfile().getProfileName()); 104 102 tabItem.setText(new File(directory).getName()); 105 103 } … … 123 121 124 122 inputDirectoryInput.setText(directory); 125 outputDirectoryInput.setText(directory + "-" + converterOptions.getCurrentProfile().getProfileName());123 outputDirectoryInput.setText(directory + "-" + ConverterOptions.getCurrentProfile().getProfileName()); 126 124 } 127 125 -
trunk/src/org/thestaticvoid/iriverter/JoinVideos.java
r32 r102 12 12 public class JoinVideos extends Composite implements SelectionListener, TabItemControl, JoinVideosInfo { 13 13 private CTabItem tabItem; 14 private ConverterOptions converterOptions;15 14 private java.util.List inputVideos; 16 15 private List videosList; … … 19 18 private String syncOutputVideo; 20 19 21 public JoinVideos(Composite parent, int style, CTabItem tabItem , ConverterOptions converterOptions) {20 public JoinVideos(Composite parent, int style, CTabItem tabItem) { 22 21 super(parent, style); 23 22 this.tabItem = tabItem; 24 this.converterOptions = converterOptions;25 23 inputVideos = new java.util.ArrayList(); 26 24 -
trunk/src/org/thestaticvoid/iriverter/LogViewer.java
r99 r102 1 1 package org.thestaticvoid.iriverter; 2 2 3 import java.io.*; 3 4 import java.util.*; 4 5 … … 10 11 import org.eclipse.swt.custom.*; 11 12 12 public class LogViewer {13 public class LogViewer implements SelectionListener { 13 14 private static LogViewer singleton; 14 15 private Shell shell; 16 private ToolItem save; 15 17 private StyledText text; 16 18 private java.util.List lineColors; … … 27 29 shell.setText("Log Viewer"); 28 30 shell.setLayout(new GridLayout()); 31 32 ToolBar toolBar = new ToolBar(shell, SWT.HORIZONTAL | SWT.FLAT); 33 34 save = new ToolItem(toolBar, SWT.PUSH); 35 InputStream is = getClass().getResourceAsStream("icons/save-24.png"); 36 save.setImage(new Image(display, is)); 37 save.addSelectionListener(this); 29 38 30 39 text = new StyledText(shell, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY); … … 48 57 } 49 58 59 public void widgetDefaultSelected(SelectionEvent e) { 60 // empty 61 } 62 63 public void widgetSelected(SelectionEvent e) { 64 if (e.getSource() == save) { 65 FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE); 66 fileDialog.setText("Output Video"); 67 fileDialog.setFilterExtensions(new String[]{"*.txt"}); 68 fileDialog.setFilterNames(new String[]{"Text Files (*.txt)"}); 69 String file = fileDialog.open(); 70 if (file != null) 71 try { 72 PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(new File(file)))); 73 74 String[] lines = Logger.getLogText().split("\n"); 75 for (int i = 0; i < lines.length; i++) 76 out.println(lines[i]); 77 78 out.close(); 79 } catch (IOException io) { 80 Logger.logMessage("Could not write file " + file, Logger.ERROR); 81 } 82 } 83 } 84 50 85 public Shell getShell() { 51 86 return shell; 87 } 88 89 public void close() { 90 shell.dispose(); 91 singleton = null; 52 92 } 53 93 -
trunk/src/org/thestaticvoid/iriverter/Logger.java
r97 r102 15 15 if (LogViewer.getSingleton() != null) 16 16 LogViewer.getSingleton().clear(); 17 18 logMessage("iriverter " + Config.VERSION + "\n", Logger.INFO); 19 logMessage("Settings:\n" + ConverterOptions.getOptionsText().trim() + "\n", Logger.INFO); 17 20 } catch (IOException e) { 18 21 e.printStackTrace(); … … 21 24 22 25 public static void logMessage(String message, int type) { 23 String[] messageLines = message.split("\n"); 24 message = ""; 25 for (int i = 0; i < messageLines.length; i++) 26 message += PREFIX[type] + messageLines[i] + (i == messageLines.length - 1 ? "" : "\n"); 26 String[] messageLines = message.split("\n", -1); 27 if (messageLines.length > 1) { 28 for (int i = 0; i < messageLines.length; i++) 29 logMessage(messageLines[i], type); 30 return; 31 } 32 33 message = PREFIX[type] + messageLines[0]; 27 34 28 35 System.out.println(message); 36 System.out.flush(); 29 37 30 38 if (output == null) … … 39 47 40 48 public static String getLogText() { 41 InputStreaminput = null;49 BufferedReader input = null; 42 50 try { 43 input = new FileInputStream(new File(System.getProperty("user.home") + File.separator + ".iriverter.log"));51 input = new BufferedReader(new FileReader(new File(System.getProperty("user.home") + File.separator + ".iriverter.log"))); 44 52 } catch (IOException e) { 45 53 // empty … … 48 56 String text = ""; 49 57 if (input != null) { 50 int read;51 byte[] buffer = new byte[4096];52 58 try { 53 while ((read = input.read(buffer)) > -1) 54 text += new String(buffer, 0, read) + "\n"; 59 String line; 60 while ((line = input.readLine()) != null) 61 text += line + "\n"; 55 62 } catch (IOException e) { 56 63 e.printStackTrace(); -
trunk/src/org/thestaticvoid/iriverter/MPlayerInfo.java
r97 r102 21 21 command = new String[]{MPlayerInfo.getMPlayerPath() + "mplayer", "-vo", "null", "-ao", "null", "-frames", "1", video.toString(), "-identify"}; 22 22 23 String commandStr = ""; 24 for (int i = 0; i < command.length; i++) 25 commandStr += command[i] + " "; 26 Logger.logMessage(commandStr, Logger.INFO); 27 23 28 try { 24 29 proc = Runtime.getRuntime().exec(command); … … 29 34 mplayerOutput = new StringBuffer(); 30 35 31 new Thread() { 32 public void run() { 33 try { 34 BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream())); 35 String line; 36 while ((line = input.readLine()) != null) { 37 mplayerOutput.append(line + "\n"); 38 Logger.logMessage(line, Logger.MPLAYER); 39 } 40 41 input.close(); 42 } catch (IOException io) { 43 io.printStackTrace(); 44 } 36 try { 37 BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream())); 38 String line; 39 while ((line = input.readLine()) != null) { 40 mplayerOutput.append(line + "\n"); 41 Logger.logMessage(line, Logger.MPLAYER); 45 42 } 46 }.start(); 47 48 new Thread() { 49 public void run() { 50 try { 51 BufferedReader input = new BufferedReader(new InputStreamReader(proc.getErrorStream())); 52 String line; 53 while ((line = input.readLine()) != null) 54 Logger.logMessage(line, Logger.MPLAYER); 55 56 input.close(); 57 } catch (IOException io) { 58 io.printStackTrace(); 59 } 60 } 61 }.start(); 62 63 try { 64 proc.waitFor(); 65 } catch (InterruptedException ie) { 66 ie.printStackTrace(); 43 44 input.close(); 45 } catch (IOException io) { 46 io.printStackTrace(); 67 47 } 68 48 } -
trunk/src/org/thestaticvoid/iriverter/ManualSplit.java
r32 r102 12 12 public class ManualSplit extends Composite implements SelectionListener, ManualSplitInfo { 13 13 private CTabItem tabItem; 14 private ConverterOptions converterOptions;15 14 private Text videoInput, hr, min, sec; 16 15 private Button videoSelect, add, remove; … … 20 19 private Mark[] syncMarks; 21 20 22 public ManualSplit(Composite parent, int style, CTabItem tabItem , ConverterOptions converterOptions) {21 public ManualSplit(Composite parent, int style, CTabItem tabItem) { 23 22 super(parent, style); 24 23 this.tabItem = tabItem; 25 this.converterOptions = converterOptions;26 24 27 25 tabItem.setText("New Manual Split"); -
trunk/src/org/thestaticvoid/iriverter/SingleVideo.java
r73 r102 12 12 public class SingleVideo extends Composite implements SelectionListener, TabItemControl, SingleVideoInfo { 13 13 private CTabItem tabItem; 14 private ConverterOptions converterOptions;15 14 private Text inputVideoInput, outputVideoInput; 16 15 private Button inputVideoSelect, outputVideoSelect; 17 16 private String syncInputVideo, syncOutputVideo; 18 17 19 public SingleVideo(Composite parent, int style, CTabItem tabItem , ConverterOptions converterOptions) {18 public SingleVideo(Composite parent, int style, CTabItem tabItem) { 20 19 super(parent, style); 21 20 this.tabItem = tabItem; 22 this.converterOptions = converterOptions;23 21 24 22 InputStream is = getClass().getResourceAsStream("icons/singlevideo-16.png"); … … 91 89 if (file != null) { 92 90 inputVideoInput.setText(file); 93 outputVideoInput.setText(file.substring(0, file.lastIndexOf('.')) + "." + converterOptions.getCurrentProfile().getProfileName() + "." + converterOptions.getCurrentProfile().getWrapperFormat());91 outputVideoInput.setText(file.substring(0, file.lastIndexOf('.')) + "." + ConverterOptions.getCurrentProfile().getProfileName() + "." + ConverterOptions.getCurrentProfile().getWrapperFormat()); 94 92 tabItem.setText(new File(file).getName()); 95 93 } … … 99 97 FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE); 100 98 fileDialog.setText("Output Video"); 101 if ( converterOptions.getCurrentProfile().getWrapperFormat().equals("mp4")) {99 if (ConverterOptions.getCurrentProfile().getWrapperFormat().equals("mp4")) { 102 100 fileDialog.setFilterExtensions(new String[]{"*.mp4"}); 103 101 fileDialog.setFilterNames(new String[]{"MP4 Video (*.mp4)"}); … … 120 118 121 119 inputVideoInput.setText(inputVideo); 122 outputVideoInput.setText(inputVideo.substring(0, inputVideo.lastIndexOf('.')) + "." + converterOptions.getCurrentProfile().getProfileName() + ".avi");120 outputVideoInput.setText(inputVideo.substring(0, inputVideo.lastIndexOf('.')) + "." + ConverterOptions.getCurrentProfile().getProfileName() + ".avi"); 123 121 } 124 122
Note: See TracChangeset
for help on using the changeset viewer.
