views:

80

answers:

1

Hi guys I wanna convert ".MOV" extentioned files to 3GP extentioned Files in java. Currently i m using Java Media Framework for creation opetion of .MOV file. But now my need is converting these videos to 3GP. I googled my issue but i couldnt get any solution. How can i do this? Any help will be appreciated.

+1  A: 

I suggest that you use xuggler (java wrapper library for ffmpeg). With their bundled ffmpeg you can test one of your videos with this command.

ffmpeg -i input.mov -acodec libamr_nb -ar 8000 -b 120000 -vcodec h263 -ab 10.2k -ac 1 output.3gp
Here is a simple class you can use with xuggler
public class AnyMediaConverter {
    public void main(String[] args) {
        //assumes the following: arg0 is input file and arg1 is output file
        IMediaReader reader = ToolFactory.makeReader(args[0]);
        IMediaWriter writer = ToolFactory.makeWriter(args[1], reader);
        writer.open();
        writer.setForceInterleave(true);
        IContainerFormat outFormat = IContainerFormat.make();
        outFormat.setOutputFormat("3gp", args[1], null);
        IContainer container = writer.getContainer();
        container.open(args[1], IContainer.Type.WRITE, outFormat);
        writer.addVideoStream(0, 0, ICodec.findEncodingCodecByName("h263"), 320, 240);
        writer.addAudioStream(1, 0, ICodec.findEncodingCodecByName("libamr_nb"), 1, 8000);
        reader.addListener(writer);
        while (reader.readPacket() == null);
    }
}
If your source audio sample rate and channels are not equal you will need to add an audio resampler (also ez to do with xuggler)

Mondain