Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

video compression using silicompressor in android not working

i am trying to compress videos in project therefore using silicompressor. but when i pass it the destination path my application gets and hang and does nothing. But it does create a folder in my storage and stores a video file but when i try to play it, it gives error "Failed to play video". And this file has size of 24 bytes. so take a look and tell what i have done wrong.

Here is my code.

File destinationPath = new File("/storage/emulated/0/DCIM/Camera/myvideo");
            destinationPath.mkdir();
            File file = new File(destinationPath.getAbsolutePath());
            Toast.makeText(Post.this, "folder: " + file, Toast.LENGTH_SHORT).show();

            try {
                filePath = SiliCompressor.with(Post.this).compressVideo(videouri, file.toString());
                video.setVideoURI(Uri.parse(filePath));
                Toast.makeText(Post.this, "Completed", Toast.LENGTH_SHORT).show();
            } catch (URISyntaxException e) {
                Log.d("EXCEPTION", e.toString());
                Toast.makeText(Post.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                e.printStackTrace();
            }
like image 499
Hasnain Ali Avatar asked Jan 29 '23 18:01

Hasnain Ali


2 Answers

Try running compression code using AsyncTask

Here you can find demo app code for video compression.

like image 189
Vinujan.S Avatar answered Feb 03 '23 07:02

Vinujan.S


I tried this SiliCompressor for video compressor, which is very well, and in this version, Audio and Video work well but not maintaining the resolution.

https://github.com/Tourenathan-G5organisation/SiliCompressor/tree/v2.2.2

Note: In the latest version(2.2.3) of SiliCompressor audio is not working after video compressor

OR

I made this and working well https://github.com/iamkdblue/CompressVideo

I hope it helps you.

like image 36
iamkdblue Avatar answered Feb 03 '23 06:02

iamkdblue