I am trying to compress a video that is recorded by a mobile camera. For that purpose, I am using the below library:
https://github.com/AbedElazizShe/LightCompressor
I am passing the captured video path and destination path. I can see it is reaching to onSuccess() method. But I can't find any compressed video on my destination path.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("Testing", "ACTIVITY REQUEST CODE " + requestCode);
switch (requestCode) {
case VIDEO_CAPTURE:
Log.d("Testing", "RESULT CODE " + resultCode);
if (data != null && resultCode == RESULT_OK) {
Uri videoUri = data.getData();
File destinationPath = new File(String.valueOf(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)));
File file = new File(destinationPath.getAbsolutePath());
Log.d("Testing", "Video Source Path:: "+currentVideoPath);
Log.d("Testing", "Video destination Path:: "+file.toString());
VideoCompressor.start(currentVideoPath, file.toString(), new CompressionListener() {
@Override
public void onStart() {
// Compression start
Log.d("Testing", "compressed onStart ");
}
@Override
public void onSuccess() {
// On Compression success
Log.d("Testing", "compressed file size ");
}
@Override
public void onFailure(String failureMessage) {
// On Failure
Log.d("Testing", "compressed onFailure ");
}
@Override
public void onProgress(float v) {
Log.d("Testing", "Progress:: ");
// Update UI with progress value
}
@Override
public void onCancelled() {
// On Cancelled
Log.d("Testing", "compressed onCancelled ");
}
}, VideoQuality.HIGH, true, true);
}else if (resultCode == RESULT_CANCELED) {
Toast.makeText(getApplicationContext(), "Video recording cancelled.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Failed to record video",
Toast.LENGTH_LONG).show();
}
break;
}
When I check the log, is I am getting:
Video Source Path::
/storage/emulated/0/Android/data/com.app.powerconsent/files/Pictures/101_20210213_194206.mp4
2021-02-13 19:42:20.287 18288-18288/com.app.powerconsent D/Testing: Video destination Path:: /storage/emulated/0/Android/data/com.app.powerconsent/files/Download
2021-02-13 19:42:20.394 18288-18288/com.app.powerconsent D/Testing: compressed onStart
2021-02-13 19:42:20.567 18288-18288/com.app.powerconsent D/Testing: compressed file size
Can someone point if is there anything going wrong? Do I need to call something using a background task?
Your destination path should point to a file and not a folder.