有人能建议我一个好的压缩器或第三方库从服务器端压缩MP4视频(我正在使用Spring )吗?
我了解了FFMPEG和Xuggler,除了这些在java中使用的可维护的压缩器之外。请给我建议或链接如下。
发布于 2018-08-10 07:14:44
使用FFMPEG包装器对视频进行压缩。以下是下载链接:https://www.ffmpeg.org/download.html
github:https://github.com/bramp/ffmpeg-cli-wrapper
在这里,代码:
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发布于 2018-04-26 12:09:49
看看jcodec
https://github.com/jcodec/jcodec
它有H.264主配置文件解码器和H.264基线配置文件编码器,完全支持MP4 /demuxer。
此外,您还可以考虑基于开放源码软件C的解决方案,并尝试C->Java转换器。这可能是一项非常困难的工作,但也会有很多好的说谎者。
https://stackoverflow.com/questions/50042483
复制相似问题