如何在Java中进行.MOV到3GP的转换操作

发布于 2024-08-31 11:06:48 字数 138 浏览 4 评论 0原文

我想将“.MOV”扩展文件转换为java中的3GP扩展文件。目前我正在使用 Java Media Framework 来创建 .MOV 文件。但现在我的需要是将这些视频转换为 3GP。我用谷歌搜索了我的问题,但找不到任何解决方案。我该怎么做?任何帮助将不胜感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的黑色迷你裙 2024-09-07 11:06:48

我建议您使用xuggler(ffmpeg的java包装库)。通过他们捆绑的 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

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)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文