简体   繁体   English

如何在java中将视频文件压缩为3gp或mp4?

[英]How to compress video file to 3gp or mp4 in java?

i am having a video file which i need to convert to 3gp, mp4 using java.我有一个视频文件,我需要使用 java 将其转换为 3gp、mp4。

is there any library to do this or any sample ?是否有任何图书馆可以做到这一点或任何示例?

if any of you have done or know the sample please guide me to do the above or provide me the example.如果你们中的任何人已经完成或知道示例,请指导我执行上述操作或提供示例。

thanks谢谢

If you MUST use Java, check Java Media Framework.如果您必须使用 Java,请检查 Java Media Framework。

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.html http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.html

Use a tool like ffmpeg ( ffmpeg.org ) or mconvert (from MPlayer ) or VLC .使用ffmpeg ( ffmpeg.org ) 或mconvert (来自MPlayer )或VLC 之类的工具 You can call them from Java using the ProcessBuilder or Commons Exec .您可以使用ProcessBuilderCommons Exec从 Java 调用它们。

You may have look at pandastream .您可能已经看过pandastream But it is a web service.但它是一个网络服务。

Compressing video in java you can use IVCompressor is very easy to use在java中压缩视频你可以用IVCompressor非常好用
for more details go https://techgnious.github.io/IVCompressor/有关更多详细信息,请访问https://techgnious.github.io/IVCompressor/

simple code简单的代码

    <dependency>
        <groupId>io.github.techgnious</groupId>
        <artifactId>IVCompressor</artifactId>
        <version>1.0.1</version>
    </dependency>

public static void main(String[] args) throws VideoException, IOException {
    IVCompressor compressor = new IVCompressor();
    IVSize customRes = new IVSize();
    customRes.setWidth(400);
    customRes.setHeight(300);
    File file = new File("D:/Testing/20.mp4");
        compressor.reduceVideoSizeAndSaveToAPath(file,VideoFormats.MP4,ResizeResolution.R480P,"D:/Testing/Custome");
    }

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

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