I have been compressing Images without any problems. Recently my app required video compress functionality to be added. Again, Silicompressor does the job but for some reason there is no audio in output file.
I am using code inside Runnable
private void compressVideo() {
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
new CompressVideo().execute("false",uri.toString(),file.getPath());
// Uri muri = Uri.parse(uri.toString());
}
@SuppressLint("StaticFieldLeak")
private class CompressVideo extends AsyncTask<String,String,String> {
@Override
protected String doInBackground(String... strings) {
String videoPath = null;
try {
Uri mUri = Uri.parse(strings[1]);
videoPath = SiliCompressor.with(PostReelActivity.this).compressVideo(mUri,strings[2]);
} catch (URISyntaxException e) {
e.printStackTrace();
}
return videoPath;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
File file = new File(s);
Uri videoUri = Uri.fromFile(file);
uploadVideo(videoUri);
}
}