我正在尝试压缩由移动相机录制的视频。为此,我正在使用以下库:
https://github.com/AbedElazizShe/LightCompressor
我正在传递捕获的视频路径和目标路径。我可以看到它正在达到 onSuccess() 方法。但我在目标路径上找不到任何压缩视频。
@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;
}
当我检查日志时,我得到的是:
视频源路径::
/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
有人可以指出是否有什么问题吗?我需要使用后台任务调用某些东西吗?