简体   繁体   English

Java中的MP4视频压缩器

[英]MP4 Video Compressor in java

Can anyone suggest me a good compressor or third party library to compress MP4 video from server side(I am using Spring MVC). 谁能建议我一个好的压缩器或第三方库来从服务器端压缩MP4视频(我正在使用Spring MVC)。

I got to know about FFMPEG and Xuggler, other than this any maintained compressors to use in java.. Please give me suggestions or links to follow. 除此以外,我还了解FFMPEG和Xuggler,并且要在Java中使用任何维护的压缩器。.请给我建议或链接。

Used FFMPEG wrapper to compress the video. 使用FFMPEG包装器压缩视频。 here's the download link: https://www.ffmpeg.org/download.html 这是下载链接: https : //www.ffmpeg.org/download.html

github: https://github.com/bramp/ffmpeg-cli-wrapper github的: https : //github.com/bramp/ffmpeg-cli-wrapper

here the code: 这里的代码:

ffmpeg = new FFmpeg("D:/ffmpeg-20180429-cae6f80-win32-static/ffmpeg-20180429-cae6f80-win32-static/bin/ffmpeg");
ffprobe = new FFprobe("D:/ffmpeg-20180429-cae6f80-win32-static/ffmpeg-20180429-cae6f80-win32-static/bin/ffprobe");

FFmpegBuilder builder = new FFmpegBuilder()
                                 .setInput(input)     // Filename, or a FFmpegProbeResult
                                 .overrideOutputFiles(true) // Override the output if it exists
                                 .addOutput(output)   // Filename for the destination
                                 .setFormat("mp4")       // Format is inferred from filename, or can be set
                             //  .setTargetSize(250_000) // Aim for a 250KB file
                                 .disableSubtitle()       // No subtiles
                                 .setAudioChannels(1)                   // Mono audio
                             //  .setAudioChannels(2)
                                 .setAudioCodec("aac")       // using the aac codec
                                 .setAudioSampleRate(48_000) // at 48KHz
                                 .setAudioBitRate(32768)     // at 32 kbit/s
                             //  .setAudioBitRate(126000)
                                 .setVideoCodec("libx264")     // Video using x264             
                                 .setVideoFrameRate(24, 1)     // at 24 frames per second
                                 .setVideoResolution(1280, 720) // at 640x480 resolution
                        //       .setVideoResolution(1024, 768)
                        //       .setVideoResolution(640, 480)
                                 .setVideoBitRate(762800)  
                                 .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL) // Allow FFmpeg to use experimental specs
                                 .done();
     FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);         
     executor.createJob(builder).run(); // Run a one-pass encode

Take a look at jcodec 看看jcodec

https://github.com/jcodec/jcodec https://github.com/jcodec/jcodec

It has H.264 main profile decoder and H.264 baseline profile encoder, altogether with MP4 muxer/demuxer support. 它具有H.264主配置文件解码器和H.264基线配置文件编码器,以及对MP4多路复用器/多路解复用器的支持。

Also, you might consider an OSS C based solution and trying out a C->Java converter. 另外,您可能会考虑基于OSS C的解决方案,并尝试使用C-> Java转换器。 It can be a horribly difficult undertaking, but there will be plenty of good libs. 这可能是一件非常困难的事情,但是会有很多不错的库。

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

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