SiliCompressor icon indicating copy to clipboard operation
SiliCompressor copied to clipboard

java.lang.IllegalArgumentException

Open vvbhandare opened this issue 8 years ago • 6 comments

I am getting below error when I pass

SiliCompressor.with(this).compressVideo("/storage/emulated/0/DCIM/Camera/VID_20170908_122018.mp4", "/storage/emulated/0/abc.mp4");

java.lang.IllegalArgumentException
at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:64)
at com.iceteck.silicompressorr.videocompression.MediaController.convertVideo(MediaController.java:252)
at com.iceteck.silicompressorr.SiliCompressor.compressVideo(SiliCompressor.java:300)
at com.xxx.farwide.coreview.activity.s3filehandling.S3FileTransactionActivity$1.run(S3FileTransactionActivity.java:74)
at java.lang.Thread.run(Thread.java:764)

vvbhandare avatar Sep 08 '17 07:09 vvbhandare

I am also getting this error any solution?

ArslanKathia avatar Sep 12 '17 05:09 ArslanKathia

Thanks both of you ( @vvbhandare & @ArslanKathia) for using this library. I'm very sorry for my late response. I was not feeling well and i have been off for some while. I have look at this issue critically and i have found that the issue is not the application(library) but the parameters you passed. The compressVideo(String videoFileUri, String destinationUri) takes two parameters of type string which are actually Uris which have been converted to string using the toString method. @vvbhandare the parameter you passed above is a path and not a uri, please use the method Uri.fromFile(new File("your-path-here")) to make your parameter a fully qualified parameter. In your case you will use it as below SiliCompressor.with(this).compressVideo(Uri.fromFile(new File("/storage/emulated/0/DCIM/Camera/VID_20170908_122018.mp4")).toString(), Uri.fromFile(new File("/storage/emulated/0/abc.mp4")).toString());

@ArslanKathia i hope the solution provided is also valid for you

I am also Getting same error while passing these as Argument for compress video . URI content://com.android.providers.media.documents/document/video%3A4500 SAVED PATH /storage/emulated/0/MyFile/Media/Video/Temp1509006345128.mp4

varun7952 avatar Oct 26 '17 08:10 varun7952

The second parameter is the destination directory, not the destination file path. Try something like this: String sourceFilePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + "/MyAppVideos/myVideo1.mp4"; String destinationDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + "/MyAppVideos/"; String compressedFilePath = SiliCompressor.with(context).compressVideo(sourceFilePath, destinationDir);

aminefilali1 avatar Dec 26 '17 16:12 aminefilali1

In my case was thrown IllegalArgumentException without any messages and causes, because MediaMetadataRetriever couldn't create FileDescriptor.

In total, works for me when videoFilePath is: /storage/emulated/0/DCIM/Camera/VID_20220226_160644.mp4

and not work when videoFilePath looks like this: file:///storage/emulated/0/DCIM/Camera/VID_20220226_160446.mp4

kirkaDev avatar Feb 26 '22 11:02 kirkaDev