Bash - 3gpToMpeg
mencoder video.3gp -o video.mpg -oac pcm -ovc lavc -lavcopts vcodec=mjpeg:mbd=1:vbitrate=1800
DZone Snippets > whitetiger > video
11376 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
mencoder video.3gp -o video.mpg -oac pcm -ovc lavc -lavcopts vcodec=mjpeg:mbd=1:vbitrate=1800
import java.awt.Dimension; import javax.media.Buffer; import javax.media.Effect; import javax.media.Format; import javax.media.ResourceUnavailableException; import javax.media.format.RGBFormat; public class SimpleFilter implements Effect { protected Format inputFormat = null; protected Format outputFormat = null; protected Format[] inputFormats = null; protected Format[] outputFormats = null; public AngelMotionCodec() { inputFormats = new Format[]{ new RGBFormat(null, Format.NOT_SPECIFIED, Format.byteArray, Format.NOT_SPECIFIED, 24, 3, 2, 1, 3, Format.NOT_SPECIFIED, Format.TRUE, Format.NOT_SPECIFIED) }; outputFormats = new Format[]{ new RGBFormat(null, Format.NOT_SPECIFIED, Format.byteArray, Format.NOT_SPECIFIED, 24, 3, 2, 1, 3, Format.NOT_SPECIFIED, Format.TRUE, Format.NOT_SPECIFIED) }; } /****** Codec ******/ public Format[] getSupportedInputFormats() { return inputFormats; } public Format[] getSupportedOutputFormats(Format input) { if(input != null) { if(matches(input, inputFormats) != null) return new Format[]{ outputFormats[0].intersects(input) }; else return new Format[0]; } return outputFormats; } public int process(Buffer input, Buffer output) { // Swap tra input & output Object tmp = input.getData(); input.setData(output.getData()); output.setData(tmp); return BUFFER_PROCESSED_OK; } public Format setInputFormat(Format input) { inputFormat = input; return input; } public Format setOutputFormat(Format output) { if(output != null || matches(output, outputFormats) != null) { RGBFormat inRGB = (RGBFormat) output; Dimension size = inRGB.getSize(); int maxDataLength = inRGB.getMaxDataLength(); int lineStride = inRGB.getLineStride(); int flipped = inRGB.getFlipped(); if(size == null) return null; if(maxDataLength < size.width*size.height*3) maxDataLength = size.width*size.height*3; if(lineStride < size.width*3) lineStride = size.width*3; if(flipped != Format.FALSE) flipped = Format.FALSE; outputFormat = outputFormats[0].intersects(new RGBFormat(size, maxDataLength, inRGB.getDataType(), inRGB.getFrameRate(), inRGB.getBitsPerPixel(), inRGB.getRedMask(), inRGB.getGreenMask(), inRGB.getBlueMask(), inRGB.getPixelStride(), lineStride, flipped, inRGB.getEndian())); return outputFormat; } return null; } /****** Codec ******/ /****** PlugIn ******/ public void close() { } public String getName() { return "Simple-Filter"; } public void open() throws ResourceUnavailableException { } public void reset() { } /****** PlugIn ******/ /****** Controls ******/ public Object getControl(String controlType) { return null; } public Object[] getControls() { return null; } /****** Controls ******/ /****** Utility ******/ private Format matches(Format in, Format[] out) { if(in != null && out != null) { for(int i=0, cnt=out.length; i<cnt; i++) { if(in.matches(out[i])) return out[i]; } } return null; } /****** Utility ******/ }
package org.jmf.example; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.metal.MetalLookAndFeel; public class ExampleJMF { public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch(UnsupportedLookAndFeelException e) { e.printStackTrace(); } new exampleFrame(); } }
package org.jmf.example; import java.awt.Toolkit; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; public class exampleFrame extends JFrame { private static final long serialVersionUID = 1L; public exampleFrame() { super("JMF - Example..."); setSize(400, 300); setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - getWidth())/2, (Toolkit.getDefaultToolkit().getScreenSize().height - getHeight())/2); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); setContentPane(new examplePanel()); setVisible(true); } }
package org.jmf.example; import java.awt.Component; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.media.ControllerEvent; import javax.media.ControllerListener; import javax.media.Manager; import javax.media.NoPlayerException; import javax.media.Player; import javax.media.RealizeCompleteEvent; import javax.swing.JPanel; public class examplePanel extends JPanel implements ActionListener, ControllerListener { private static final long serialVersionUID = 1L; private Component visualComponent; private Player player; public examplePanel() { try { player = Manager.createPlayer(new URL("file:///tmp/a.mpg")); player.addControllerListener(this); player.start(); } catch(NoPlayerException e) { e.printStackTrace(); } catch(MalformedURLException e) { e.printStackTrace(); } catch(IOException e) { e.printStackTrace(); } } public void paintComponent(Graphics g) { super.paintComponent(g); } public void actionPerformed(ActionEvent e) { } public void controllerUpdate(ControllerEvent c) { if(player == null) return; if(c instanceof RealizeCompleteEvent) { if((visualComponent = player.getVisualComponent()) != null) add(visualComponent); } } }