首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >java中的MP4视频压缩器

java中的MP4视频压缩器
EN

Stack Overflow用户
提问于 2018-04-26 12:01:35
回答 2查看 7K关注 0票数 1

有人能建议我一个好的压缩器或第三方库从服务器端压缩MP4视频(我正在使用Spring )吗?

我了解了FFMPEG和Xuggler,除了这些在java中使用的可维护的压缩器之外。请给我建议或链接如下。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-08-10 07:14:44

使用FFMPEG包装器对视频进行压缩。以下是下载链接:https://www.ffmpeg.org/download.html

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

在这里,代码:

代码语言:javascript
运行
复制
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
票数 1
EN

Stack Overflow用户

发布于 2018-04-26 12:09:49

看看jcodec

https://github.com/jcodec/jcodec

它有H.264主配置文件解码器和H.264基线配置文件编码器,完全支持MP4 /demuxer。

此外,您还可以考虑基于开放源码软件C的解决方案,并尝试C->Java转换器。这可能是一项非常困难的工作,但也会有很多好的说谎者。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50042483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档