Friday, August 19, 2011

Different and best Swings Look and feel Themes


Here is the code

package com.gui;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class MainGUI extends JPanel implements ActionListener {

private static final long serialVersionUID = 1L;
private JButton jbmMetal = new JButton("Metal");
private JButton jbnMotif = new JButton("Motif");
private JButton jbnWindows = new JButton("Windows");
private JButton jbnliquid = new JButton("Liquid");
private JButton jbnstick = new JButton("Stick");
private JButton tatto = new JButton("JTatto Aluminium");
private JButton acryltatto = new JButton("JTatto Acryl");
private JButton Aerotatto = new JButton("JTatto Aero");
private JButton beristeintatto = new JButton("JTatto Bernstein");
private JButton lunatatto = new JButton("JTatto Luna");
private JButton minttatto = new JButton("JTatto mint");
private JButton smarttatto = new JButton("JTatto Smart");
private JButton hifitatto = new JButton("JTatto HiFi");
private JButton quaqua = new JButton("QuaQua");
public MainGUI() {
add(jbmMetal);
add(jbnMotif);
add(jbnWindows);
add(jbnliquid);
add(jbnstick);
add(tatto);
add(acryltatto);
add(Aerotatto);
add(beristeintatto);
add(lunatatto);
add(minttatto);
add(smarttatto);
add(hifitatto);
add(quaqua);
jbmMetal.addActionListener(this);
jbnMotif.addActionListener(this);
jbnWindows.addActionListener(this);
jbnliquid.addActionListener(this);
jbnstick.addActionListener(this);
tatto.addActionListener(this);
acryltatto.addActionListener(this);
Aerotatto.addActionListener(this);
beristeintatto.addActionListener(this);
lunatatto.addActionListener(this);
minttatto.addActionListener(this);
smarttatto.addActionListener(this);
hifitatto.addActionListener(this);
quaqua.addActionListener(this);
}


public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
String laf = "";
if (source == jbmMetal)
laf = "javax.swing.plaf.metal.MetalLookAndFeel";
else if (source == jbnMotif)
laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
else if (source == jbnWindows)
laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
else if (source == jbnliquid)
laf = "com.birosoft.liquid.LiquidLookAndFeel";
else if (source == jbnstick)
laf = "com.lipstikLF.LipstikLookAndFeel";
else if (source == tatto)
laf = "com.jtattoo.plaf.aluminium.AluminiumLookAndFeel";
else if (source == acryltatto)
laf = "com.jtattoo.plaf.acryl.AcrylLookAndFeel";
else if (source == Aerotatto)
laf = "com.jtattoo.plaf.aero.AeroLookAndFeel";
else if (source == beristeintatto)
laf = "com.jtattoo.plaf.bernstein.BernsteinLookAndFeel";
else if (source == lunatatto)
laf = "com.jtattoo.plaf.luna.LunaLookAndFeel";
else if (source == minttatto)
laf = "com.jtattoo.plaf.mint.MintLookAndFeel";
else if (source == smarttatto)
laf = "com.jtattoo.plaf.smart.SmartLookAndFeel";
else if (source == hifitatto)
laf = "com.jtattoo.plaf.hifi.HiFiLookAndFeel";
else if (source == quaqua)
laf = "ch.randelshofer.quaqua.QuaquaLookAndFeel";

try {
UIManager.setLookAndFeel(laf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception excep) {
}
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setTitle("Look and Feel Test");
frame.setSize(500, 300);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Container contentPane = frame.getContentPane();
contentPane.add(new MainGUI());
frame.setVisible(true);
Calculator calculator = new Calculator();
}


}

4 third party jars need to download

liquidlnf.jar
lipstikLF-1.1.jar
JTattoo.jar
quaqua.jar
quaqua-filechooser-only.jar

Wednesday, August 10, 2011

Converting audio/video files using ffmpeg

ffmpeg command can be used to convert the audio/video from one format to another format

Common ffmpeg Parameters
  • -i - Path\Filename of source file
  • -y - Overwrite the existing output file without prompting
  • -an - Disable audio
Video Related ffmpeg Parameters
  • -aspect - Set Aspect Ratio for the video (4:3, 16:9 or 1.3333, 1.7777)
  • -r - Set frame rate in Hz for the video
  • -s - Set video resolution size (Width x Height)
  • -sameq - Use same video quality as source
Audio Related ffmpeg Parameters
  • -ar - Set audio sampling rate (in Hz)
  • -acodec - Force audio codec, example mp3
  • -vol - Change audio volume (256=normal)
  • -ab - Set audio bit rate (in bits/s)
Syntax
ffmpeg Command

Video
  • Converting MOV to FLV using FFMPEG:
    ffmpeg -i movie.mov movie.flv
  • Converting Mpeg to FLV using FFMPEG:
    ffmpeg -i movie.mpeg movie.flv
  • Converting AVI to FLV using FFMPEG - convert movie.avi to movie.flv and resize the video resolution to 500×500:
    ffmpeg -i movie.avi -s 500×500 movie.flv
  • Converting 3GP to FLV using FFMPEG - convert movie.3gp to movie.flv, keep the original file settings and disable the audio content:
    ffmpeg -i movie.3gp -sameq -an movie.flv
  • Converting MPEG to 3GP using FFMPEG:
    ffmpeg -i movie.mpeg -ab 8.85k -acodec libamr_wb -ac 1 -ar 16000 -vcodec h263 -s qcif movie2.3gp
Audio

  • Converting aac to mp3 using FFMPEG with MetaData - convert audio.aac to audio.mp3 with an audio rate of 22.05 Khz and audio BitRate of 32Khz, and will copy the metadata from .aac file to .mp3 file:
    ffmpeg -i audio.aac -ar 22050 -ab 32 -map_meta_data audio.mp3:audio.aac audio.mp3
  • Converting WMV to MP3 using FFMPEG
    ffmpeg -i audio.wmv audio.mp3
  • Converting WMV to FLV using FFMPEG - convert audio.wmv to audio.flv, generating only audio content:
    ffmpeg -i audio.wmv audio.flv
  • Converting AMR to MP3 using FFMPEG - convert audio.amr to audio.mp3, with an audio rate of 22.05 Khz:
    ffmpeg -i audio.amr -ar 22050 audio.mp3
  • Converting aac to mp3 using FFMPEG - convert audio.aac to audio.mp3, with an audio rate of 22.05 Khz and audio BitRate or 32Khz:
    ffmpeg -i audio.aac -ar 22050 -ab 32 audio.mp3
FFmpeg download

http://ffmpeg.arrozcru.org/autobuilds/


convert avi to flv like in youtube

ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv