[Mediaconverter-commits] r20 - MediaConverter/src/mediaconverter
konttori at garage.maemo.org
konttori at garage.maemo.org
Sun Jan 7 22:17:19 EET 2007
Author: konttori
Date: 2007-01-07 22:17:19 +0200 (Sun, 07 Jan 2007)
New Revision: 20
Modified:
MediaConverter/src/mediaconverter/MainWindow.form
MediaConverter/src/mediaconverter/MainWindow.java
Log:
Updating to 1.21 version. Fixing some minor bugs and adding support for resolution text file. Maybe will add text file editor at some point as well, but for now this'll have to do it.
Modified: MediaConverter/src/mediaconverter/MainWindow.form
===================================================================
--- MediaConverter/src/mediaconverter/MainWindow.form 2006-11-07 09:32:18 UTC (rev 19)
+++ MediaConverter/src/mediaconverter/MainWindow.form 2007-01-07 20:17:19 UTC (rev 20)
@@ -228,7 +228,7 @@
<Component class="javax.swing.JSlider" name="videoSlider">
<Properties>
<Property name="majorTickSpacing" type="int" value="128"/>
- <Property name="maximum" type="int" value="512"/>
+ <Property name="maximum" type="int" value="768"/>
<Property name="minimum" type="int" value="128"/>
<Property name="minorTickSpacing" type="int" value="64"/>
<Property name="paintLabels" type="boolean" value="true"/>
@@ -290,7 +290,7 @@
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JComboBox(availableResolutions);"/>
- <AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value="String[] availableResolutions = {"Low Quality (240x144)","Medium Quality (288x208)","High Quality (352x208), 17 FPS","Very High Quality (352x288)","MPLAYER OPTIMIZED"}; "/>
+ <AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value="String[] availableResolutions = {"Low Quality (240x144)","Medium Quality (288x208)","High Quality (352x208) 3/4 fps","Very High Quality (352x288) half fps","MPLAYER OPTIMIZED"}; "/>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="resolutionBox.setSelectedIndex(2);"/>
</AuxValues>
<Constraints>
@@ -399,7 +399,6 @@
</Component>
<Component class="javax.swing.JCheckBox" name="enhanceColorCheckBox">
<Properties>
- <Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Enhance Color"/>
</Properties>
<Events>
@@ -426,7 +425,7 @@
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
- <Property name="text" type="java.lang.String" value="MC Version 1.2"/>
+ <Property name="text" type="java.lang.String" value="MC Version 1.21"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
Modified: MediaConverter/src/mediaconverter/MainWindow.java
===================================================================
--- MediaConverter/src/mediaconverter/MainWindow.java 2006-11-07 09:32:18 UTC (rev 19)
+++ MediaConverter/src/mediaconverter/MainWindow.java 2007-01-07 20:17:19 UTC (rev 20)
@@ -50,12 +50,11 @@
column.setPreferredWidth(240);
column.setHeaderValue("File");
+ loadResolutions();
+ System.err.println(System.getProperty("user.dir"));
- //System.err.println(System.getProperty("user.dir"));
-
-
Hashtable labelTable = new Hashtable();
labelTable.put( new Integer( 0 ), new JLabel("No audio") );
labelTable.put( new Integer( 32 ), new JLabel("32") );
@@ -108,6 +107,33 @@
}
+ public void loadResolutions() {
+
+ try {
+ File f=new File("resolutions.txt");
+ FileInputStream in= new FileInputStream(f);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+
+ //Ok, file exists. Now remove default resolutions
+ resolutionBox.removeAllItems();
+ String str;
+ StringBuffer buffer=new java.lang.StringBuffer();
+
+ while ((str = reader.readLine()) != null) {
+ resolutionBox.addItem(new String(str));
+
+ }
+
+
+ reader.close();
+ in.close();
+ } catch (Exception e) {
+ System.err.println("Something wrong with loading of resolutions. ");
+ }
+
+ }
+
+
//DRAGNDROP STUFF... REALLY INTERESTING!
class TextDropTargetListener implements DropTargetListener {
public TextDropTargetListener(JTextArea ta) {
@@ -236,7 +262,7 @@
jLabel2 = new javax.swing.JLabel();
audioSlider = new javax.swing.JSlider();
jLabel3 = new javax.swing.JLabel();
- String[] availableResolutions = {"Low Quality (240x144)","Medium Quality (288x208)","High Quality (352x208), 17 FPS","Very High Quality (352x288)","MPLAYER OPTIMIZED"};
+ String[] availableResolutions = {"Low Quality (240x144)","Medium Quality (288x208)","High Quality (352x208) 3/4 fps","Very High Quality (352x288) half fps","MPLAYER OPTIMIZED"};
resolutionBox = new JComboBox(availableResolutions);
jLabel4 = new javax.swing.JLabel();
vhqCheckBox = new javax.swing.JCheckBox();
@@ -358,7 +384,7 @@
jPanel2.setMinimumSize(new java.awt.Dimension(310, 310));
jPanel2.setPreferredSize(new java.awt.Dimension(845, 430));
videoSlider.setMajorTickSpacing(128);
- videoSlider.setMaximum(512);
+ videoSlider.setMaximum(768);
videoSlider.setMinimum(128);
videoSlider.setMinorTickSpacing(64);
videoSlider.setPaintLabels(true);
@@ -437,7 +463,6 @@
subtitleSelection.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "None", "ANSI", "UTF-8" }));
jPanel2.add(subtitleSelection, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 180, 230, -1));
- enhanceColorCheckBox.setSelected(true);
enhanceColorCheckBox.setText("Enhance Color");
enhanceColorCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -456,7 +481,7 @@
jPanel2.add(audioGainCB, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 330, 290, 20));
- jLabel13.setText("MC Version 1.2");
+ jLabel13.setText("MC Version 1.21");
jPanel2.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 386, -1, 30));
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
@@ -702,24 +727,25 @@
private void resolutionBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resolutionBoxActionPerformed
- String selectedResolution = (String) resolutionBox.getSelectedItem();
- if (selectedResolution.indexOf("352x208")>-1) {
- videoSlider.setValue(384);
- }
- if (selectedResolution.indexOf("352x288")>-1) {
- videoSlider.setValue(512);
- }
-
- if (selectedResolution.indexOf("144")>-1) {
- videoSlider.setValue(128);
- }
- if (selectedResolution.indexOf("288x")>-1) {
- videoSlider.setValue(256);
- }
- if (selectedResolution.indexOf("MPLAYER")>-1) {
- videoSlider.setValue(512);
- }
-
+ String selectedResolution = (String) resolutionBox.getSelectedItem();
+ if (selectedResolution!=null) {
+ if (selectedResolution.indexOf("352x208")>-1) {
+ videoSlider.setValue(384);
+ }
+ if (selectedResolution.indexOf("352x288")>-1) {
+ videoSlider.setValue(512);
+ }
+
+ if (selectedResolution.indexOf("144")>-1) {
+ videoSlider.setValue(128);
+ }
+ if (selectedResolution.indexOf("288x")>-1) {
+ videoSlider.setValue(256);
+ }
+ if (selectedResolution.indexOf("MPLAYER")>-1) {
+ videoSlider.setValue(512);
+ }
+ }
}//GEN-LAST:event_resolutionBoxActionPerformed
private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed
@@ -813,7 +839,7 @@
//MENCODER HACK - Move to a better place when more time
if (!optimizeCheckBox.isSelected()) {
- if (selectedResolution.indexOf("400")>-1) {
+ if (selectedResolution.indexOf("400:240")>-1) {
if (videoAspect>1.32 && videoAspect<1.34) {
aspectString="aspect=4/3";
selectedResolution="320:240";
@@ -830,9 +856,10 @@
}
}
- }
- fpsString = setOutputFPS(fpsString, selectedResolution);
+ }
+ fpsString = setOutputFPS(fpsString, (String) resolutionBox.getSelectedItem());
+
cmd[2]=mencoderName;
if (previewOnly) previewString="-endpos 00:00:30 -ss 30 ";
String subtitlestring = setSubtitleString(fileString);
@@ -840,7 +867,7 @@
String colorEnhancerString="";
String audioEnhancerString="";
if (enhanceColorCheckBox.isSelected()) colorEnhancerString=",eq2=1.4:1.2:0.0:1.4";
- if (codecString=="mpeg1video") cmd[2]+=" \""+ fileString+"\" -noskip -oac lavc -lavcopts acodec=mp2:abitrate="+audioSlider.getValue()+" -ofps 25 -of mpeg -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate="+videoSlider.getValue()+":vrc_minrate=64:vrc_maxrate=2600:vrc_buf_size=917:keyint=25:vlelim=-4:vcelim=7:trell:mbd=2:vratetol=10000000 -vf scale="+selectedResolution+" "+subtitlestring+" -o "+targetfile+".mpg";
+ if (codecString.equals("mpeg1video")) cmd[2]+=" \""+ fileString+"\" -noskip -oac lavc -lavcopts acodec=mp2:abitrate="+audioSlider.getValue()+" -ofps 25 -of mpeg -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate="+videoSlider.getValue()+":vrc_minrate=64:vrc_maxrate=2600:vrc_buf_size=917:keyint=25:vlelim=-4:vcelim=7:trell:mbd=2:vratetol=10000000 -vf scale="+selectedResolution+" "+subtitlestring+" -o "+targetfile+".mpg";
else {
//tcplx_mask changes how fast movement video is encoded. Higher values mean bigger blocks in high movement and lower framerate then.0.0 as default.
//dark mask effects the way dark scenes are encoded. Bigger value means smaller video size (and less detail in the dark). 0.0 as default.
@@ -855,10 +882,10 @@
if (vhq)
cmd[2]+=" \""+ fileString+"\" "+priorityString+" "+audioOptions+" "+demuxerString+" -ovc lavc -lavcopts vcodec="+codecString+":dark_mask=0.15:"+aspectString+":vbitrate="+videoSlider.getValue()+":trell=yes:v4mv=yes:vpass=1 -vf "+cropString+"scale="+selectedResolution+colorEnhancerString+" -idx -ffourcc DIVX "+subtitlestring+" "+fpsString+" "+previewString+" -o "+targetfile;
else
- cmd[2]+=" \""+ fileString+"\" "+priorityString+" "+audioOptions+" "+demuxerString+" -ovc lavc -lavcopts vcodec="+codecString+":dark_mask=0.15:"+aspectString+":vbitrate="+videoSlider.getValue()+":trell=yes:v4mv=yes:vpass=1 -vf "+cropString+"scale="+selectedResolution+colorEnhancerString+" -idx -ffourcc DIVX "+subtitlestring+" "+fpsString+" "+previewString+" -o "+targetfile;
+ cmd[2]+=" \""+ fileString+"\" "+priorityString+" "+audioOptions+" "+demuxerString+" -ovc lavc -lavcopts vcodec="+codecString+":dark_mask=0.15:"+aspectString+":vbitrate="+videoSlider.getValue()+":trell=yes:v4mv=yes -vf "+cropString+"scale="+selectedResolution+colorEnhancerString+" -idx -ffourcc DIVX "+subtitlestring+" "+fpsString+" "+previewString+" -o "+targetfile;
}
+
-
errorConsole.append("Converting video "+fileString+"\n ");
if (fullTraceCB.isSelected()) errorConsole.append("Execution conversion with: "+cmd[2]+"\n");
if (vhq) errorConsole.append("First pass:\n ");
@@ -951,6 +978,7 @@
+
if (selectedResolution.indexOf("176x144")>-1) selectedResolution="176:144";
if (selectedResolution.indexOf("240x144")>-1) selectedResolution="240:144";
if (selectedResolution.indexOf("288x160")>-1) selectedResolution="288:160";
@@ -960,9 +988,15 @@
if (selectedResolution.indexOf("352x208")>-1) selectedResolution="352:208";
if (selectedResolution.indexOf("352x288")>-1) selectedResolution="352:288";
if (selectedResolution.indexOf("352x240")>-1) selectedResolution="352:240";
- if (selectedResolution.indexOf("400x240")>-1) selectedResolution="400:240";
- if (selectedResolution.indexOf("MPLAYER")>-1) selectedResolution="400:240";
-
+ if (selectedResolution.indexOf("400x240")>-1) selectedResolution="400:240";
+ if (selectedResolution.indexOf("400x480")>-1) selectedResolution="400:480";
+
+ if (selectedResolution.indexOf(":")==-1 && selectedResolution.indexOf("(")>-1 && selectedResolution.indexOf(")")>-1) {
+ System.err.println(selectedResolution.indexOf("("));
+ selectedResolution=selectedResolution.substring(selectedResolution.indexOf("(")+1,selectedResolution.indexOf(")"));
+ selectedResolution=selectedResolution.replaceAll("x",":");
+ }
+ //System.err.println("resolution set to: "+selectedResolution);
return selectedResolution;
}
@@ -1014,37 +1048,42 @@
private String setOutputFPS(String fpsString, final String selectedResolution) throws NumberFormatException {
- //ALL SET TO HALF SPEED UNTIL 2006 final release!!
+
fpsString="-ofps 15";
boolean halfspeed=false;
boolean morethanhalfspeed=false;
+ boolean lessthanhalfspeed=false;
//SET FPS AS NEEDED
- if (selectedResolution.indexOf("352:208")>-1) {
- fpsString="-ofps 17";
- //halfspeed=true;
+ if (selectedResolution.indexOf("1/2 fps")>-1) {
+ halfspeed=true;
+ }
+ if (selectedResolution.indexOf("3/4 fps")>-1) {
morethanhalfspeed=true;
}
- if (selectedResolution.indexOf("352:288")>-1) {
- fpsString="-ofps 15";
- halfspeed=true;
+
+
+ if (selectedResolution.indexOf("3/8 fps")>-1) {
+ lessthanhalfspeed=true;
}
- //mplayer case
- if (selectedResolution.indexOf("400")>-1 || selectedResolution.indexOf(":240")>-1) {
- //fpsString="-ofps 20";
- //halfspeed=true;
+
+ if (selectedResolution.indexOf("10 fps")>-1) {
+ fpsString="-ofps 10";
}
- if (selectedResolution.indexOf("288:208")>-1) {
- //fpsString="-ofps 15";
- //halfspeed=true;
+
+ if (selectedResolution.indexOf("5 fps")>-1) {
+ fpsString="-ofps 5";
}
+
+
//Basically if needed to half fps
if (fileFPSString!=null && fileFPSString!="") {
double fileFPS=new Double(fileFPSString).doubleValue();
if (halfspeed) fileFPS=fileFPS/2;
if (morethanhalfspeed) fileFPS=fileFPS*0.75;
+ if (lessthanhalfspeed) fileFPS=fileFPS*(3.0/8.0);
- if (fpsString!="" && fileFPS<30 && fileFPS>2) {
+ if (fpsString!="" && fileFPS<30 && fileFPS>1) {
fpsString="-ofps "+fileFPS;
errorConsole.append ("\nfps set: "+fpsString);
}
@@ -1096,7 +1135,10 @@
if (aspect < idealRatio) {
cropHeight -= (int) cropHeight * newRatio;
}
- if (aspect>14.5/9.0 && aspect<19.5/9.0) resolutionToFullScreeen=true;
+ if (aspect>14.5/9.0 && aspect<16.5/9.0) {
+ resolutionToFullScreeen=true;
+ errorConsole.append("\nSettign aspect to fullscreen because so close to 770 aspect. ("+aspect+")");
+ }
if (optimizeCheckBox.isSelected()) {
cropString= "crop="+cropWidth+":"+cropHeight+",";
resolutionToFullScreeen=true;
@@ -1201,7 +1243,7 @@
if (line.length()>0) processed=(int) (3*(new Integer(line).intValue()));
- errorConsole.append("\nprocessing with preview"+line +" "+processed);
+ //errorConsole.append("\nprocessing with preview"+line +" "+processed);
} else {
line=line.substring(position-2,position);
More information about the Mediaconverter-commits
mailing list