AbedElazizShe / LightCompressor

A powerful and easy-to-use video compression library for android uses MediaCodec API.
Apache License 2.0
518 stars 117 forks source link

Video Quality is too low even after selecting HIGH,MEDIUM,LOW #31

Closed Suyash171 closed 4 years ago

AbedElazizShe commented 4 years ago

Thank you for openning this issue. Please share the video's original size and bitrate if you can, and a snippet of where you call the compressor.

You can set to keep the original size of the video or skipping the compression if the bitrate is below 2mbps.

Suyash171 commented 4 years ago

Video Size 1.22 MB , Resolution :- 480*852

private void compressVideoWithAbd(String videoPath){

    File root = android.os.Environment.getExternalStorageDirectory();
    File file = new File(root.getAbsolutePath() + Constants.DIRECTORY_STRUCTURE.APP_DIRECTORY.concat(Constants.DIRECTORY_STRUCTURE.APP_FOLDER_VIDEO).concat("/Compressed/"));
    if (!file.exists()) {
        file.mkdirs();
    }
    String filePath = null;
    File videoFile = new File(file.getPath().concat("/").concat(String.valueOf(System.currentTimeMillis())).concat(".mp4"));

    VideoCompressor.start(videoPath, videoFile.getPath(), new CompressionListener() {
        @Override
        public void onStart() {
            // Compression start
        }

        @Override
        public void onSuccess() {
            // On Compression success

            isVideoCompressEnable--;
            //  String text = String.format(Locale.US, "%s\nName: %s\nSize: %s", "completed", videoFile.getName(), s.getOutput());
            //String msg = String.format("compress completed \ntake time:%s \nout put file:%s", s.getCostTime(), s.getOutput());
            //Log.d("Time", "Cost" + msg);

        }

        @Override
        public void onFailure(String failureMessage) {
            // On Failure

        }

        @Override
        public void onProgress(float progressPercent) {
            // Update UI with progress value
            Executors.newCachedThreadPool().execute(() -> {
                Log.d("Video Compresssor" , " Progress " + progressPercent + "%");
            });
        }

        @Override
        public void onCancelled() {
            // On Cancelled

        }
    }, VideoQuality.MEDIUM, false, false);
}
AbedElazizShe commented 4 years ago

Thank you for the provided details. The video size is very very small and I assume its bitrate too. No matter what you do, the quality won't be as you expect. Do you really wan to compress video this size ?

What you can do it to allow the library to determine if the video should be compressed or not, and that can be achieved by changing the isMinBitrateEnabled argument to true

}, VideoQuality.MEDIUM, true, false);

If the library determines it should not be compressed, you will receive a failure message so you can just use your original video as it is small enough.

Thank you, feel free to open the issue if you have any question

Suyash171 commented 4 years ago

Yes. it worked thank you for kindly information and help @AbedElazizShe Great work