Tuesday, 18 June 2013

Xuggler Video Conversion .mov to .mp4

Jars Required
1. commons-cli-1.1
2. logback-classic-1.0.0
3. logback-core-1.0.0
4. slf4j-api-1.6.4
5. xuggle-xuggler-5.4

import com.xuggle.mediatool.IMediaReader;
import com.xuggle.mediatool.IMediaViewer;
import com.xuggle.mediatool.IMediaWriter;
import com.xuggle.mediatool.ToolFactory;

public class TranscodingExample {

 private static final String inputFilename ="/home/harry/Portrait.MOV";
 private static final String outputFilename ="/home/harry/sample.mp4";

 public static void main(String[] args) {

  Long st = System.currentTimeMillis();
  // create a media reader
  IMediaReader mediaReader = ToolFactory.makeReader(inputFilename);
  // create a media writer
  IMediaWriter mediaWriter = ToolFactory.makeWriter(outputFilename, mediaReader);

  // add a writer to the reader, to create the output file
  // create a media viewer with stats enabled
  IMediaViewer mediaViewer = ToolFactory.makeViewer(true);
  // add a viewer to the reader, to see the decoded media

  // read and decode packets from the source file and
  // and dispatch decoded audio and video to the writer
  while (mediaReader.readPacket() == null) ;
  Long end = System.currentTimeMillis();
  System.out.println("Time Taken In Milli Seconds: "+ (end-st));



Download Working Project Here


  1. I am getting this error :
    com.xuggle.xuggler - Got error: picture is not of the same PixelType as this Coder expected (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1430)
    Does anyone know how to solve it ?


Related Posts Plugin for WordPress, Blogger...