简体   繁体   English

如何在Java中将.MOV转换为3GP

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

I wanna convert ".MOV" extentioned files to 3GP extentioned Files in java. 我想在Java中将“ .MOV”扩展文件转换为3GP扩展文件。 Currently im using Java Media Framework for creation opetion of .MOV file. 目前,我使用Java Media Framework创建.MOV文件。 But now my need is converting these videos to 3GP. 但是现在我需要将这些视频转换为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). 我建议您使用xuggler(ffmpeg的Java包装器库)。 With their bundled ffmpeg you can test one of your videos with this command. 通过捆绑的ffmpeg,您可以使用此命令测试其中一个视频。


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 这是一个可以与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) 如果您的源音频采样率和声道不相等,则需要添加一个音频重采样器(还有ez用于xuggler)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM