1

Can anyone suggest me a good compressor or third party library to compress MP4 video from server side(I am using 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.

User
  • 89
  • 2
  • 13
  • 1
    go for FFMPEG its open source and well documented also it has h264 and h265 video encoders so you have a choice too to go with one which ever suits your requirments. for further info (http://ffmpeg.org/ffmpeg-all.html) – Awais fiaz Apr 26 '18 at 12:06
  • 1
    installation guide for FFMPEG (https://trac.ffmpeg.org/wiki/CompilationGuide/) – Awais fiaz Apr 26 '18 at 12:09
  • Thank you for your reply. I will go through the link you suggest. – User Apr 26 '18 at 12:09
  • 1
    you'r welcome suggest you FFMPEG because its very easy to use rest depends on your choice – Awais fiaz Apr 26 '18 at 12:11
  • Do you have any example links? if you have please post here. – User Apr 26 '18 at 12:15

2 Answers2

1

Used FFMPEG wrapper to compress the video. here's the download link: https://www.ffmpeg.org/download.html

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
User
  • 89
  • 2
  • 13
0

Take a look at 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.

Also, you might consider an OSS C based solution and trying out a C->Java converter. It can be a horribly difficult undertaking, but there will be plenty of good libs.

Mikhail Kholodkov
  • 23,642
  • 17
  • 61
  • 78