4

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();
            }
Hasnain Ali
  • 53
  • 1
  • 7
  • 1
    Hang probably means that the compression is happening on the main thread, check the lib if you need to execute on a different thread – Veneet Reddy Aug 20 '17 at 18:20

2 Answers2

8

Try running compression code using AsyncTask

Here you can find demo app code for video compression.

Vinujan.S
  • 1,199
  • 14
  • 27
  • can explain me more & give the code about this? I really need this help, – Masterpiece Mas Icang Oct 10 '18 at 15:59
  • Hi, code is in this link https://github.com/Tourenathan-G5organisation/SiliCompressor/blob/5db57524310d4ab8b79f97bd6b8861c659000dd6/app/src/main/java/com/iceteck/silicompressor/SelectPictureActivity.java#L319 . Regarding what you need explanation? – Vinujan.S Oct 10 '18 at 16:04
  • it gives me like this "Surface frame wait timed out" but my video not showing, should i give progressdialog? – Masterpiece Mas Icang Oct 10 '18 at 16:10
  • 10-10 23:14:04.049 15345-15820/id.gis.collection E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found 10-10 23:14:04.071 15345-15820/id.gis.collection I/ExtendedExtractor: ExtendedExtractor::create 0x0 10-10 23:14:04.141 15345-15820/id.gis.collection E/tmessages: colorFormat = 2130708361 – Masterpiece Mas Icang Oct 10 '18 at 16:17
  • It is clearly says libwvm.so library file not found... So please check your dependencies... Better clean and re install or reconfigure it – Vinujan.S Oct 10 '18 at 16:20
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181629/discussion-between-masterpiece-mas-icang-and-vinujan-s). – Masterpiece Mas Icang Oct 10 '18 at 17:17
1

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.

iamkdblue
  • 3,448
  • 2
  • 25
  • 43