开发者

How to make convert operation from .MOV to 3GP in Java

I wanna convert ".MOV" extenti开发者_高级运维oned 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.


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜