简体   繁体   中英

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.

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.

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 . You can call them from Java using the ProcessBuilder or Commons Exec .

You may have look at pandastream . But it is a web service.

Compressing video in java you can use IVCompressor is very easy to use
for more details go 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");
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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