How to reduce the size of video in Android? [close

2020-06-27 09:18发布

问题:

I am new to Android .I don't know how to compress the video in android .

Please, suggest me the options?

回答1:

You can try Intel INDE on https://software.intel.com/en-us/intel-inde and Media Pack for Android which is a part of INDE, tutorials on https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android- . It has a sample that shows how to use media pack to transcode=recompress video files.

You can set smaller resolution and\or bitrate to output to get smaller file in ComposerTranscodeCoreActivity.java

protected void setTranscodeParameters(MediaComposer mediaComposer) throws  IOException {

  mediaComposer.addSourceFile(mediaUri1);
  mediaComposer.setTargetFile(dstMediaPath);

  configureVideoEncoder(mediaComposer, videoWidthOut, videoHeightOut);
  configureAudioEncoder(mediaComposer);
}

protected void transcode() throws Exception {

  factory = new AndroidMediaObjectFactory(getApplicationContext());
  mediaComposer = new MediaComposer(factory, progressListener);
  setTranscodeParameters(mediaComposer);
  mediaComposer.start();
}


回答2:

I had the same problem, so...I took the video compression code from the Telegram for android source code and created a sample project for that, here it is:

https://github.com/lalongooo/VideoCompressor