Closed onaburalnyionseo closed 3 years ago
did you pass video path TrimVideo.activity(String.valueOf(data.getData()))
in this constructor. this error might happen if you pass videopath instead of videouri. Can you share the device details?
My device is Google Pixel XL. Android 10 (QP1A.191005.007.A3)
I create intent and execute: Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("video/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); fragment.startActivityForResult(intent, 2);
and in onActivityResult: if (requestCode == 2 && data != null) { if (data.getData() != null) { TrimVideo.activity(String.valueOf(data.getData())) .setTrimType(TrimType.MIN_MAX_DURATION) .setMinToMax(5, 60).start(fragment); } else { Toast.makeText(fragment.getContext(), "video uri is null", Toast.LENGTH_SHORT).show(); } } else if (requestCode == TrimVideo.VIDEO_TRIMMER_REQ_CODE && data != null) { Uri TrimmedVideoUri = Uri.parse(TrimVideo.getTrimmedVideoPath(data)); }
@a914-gowtham any ideas ?
I'll try to reproduce it here
@a914-gowtham Did you manage to reproduce this defect?
@onaburalnyionseo I couldn't reproduce the issue. I tried the latest release with Pixel XL emulator android 10. can you share the library version you used
com.github.a914-gowtham:Android-video-trimmer:1.6.1
@onaburalnyionseo Really Sorry for late response.
You can use this implementation 'com.github.a914-gowtham:Android-video-trimmer:b6fe3a90f8'
snapshot it will be available in the next release. now copyToInternalStorage method runs in background.
@a914-gowtham Well thank you! I will try on this week and let you know the result. When I can expected marge this fix in the main branch?
@onaburalnyionseo If you verify the fix. I can make a release within a day.
copyToInternelStorage is not the correct way when I try to trim a video from getExternalStorageDirectory() it throws fileNotFoundException. that's why I used copyToInternelStorage as a workaround. I will try to find any other solution instead of copyToInternelStorage.
@a914-gowtham Could not find com.github.a914-gowtham:Android-video-trimmer:b6fe3a90f8.
@onaburalnyionseo Make sure to add the jitpack maven in build.gradle(project)
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
@a914-gowtham At first glance, everything is fine. But i think you don't must copy video to app folder because app size very increase. I think the best solution is load video to preview from original video path and save to app folder only trimmed video. What do you think about this solution? Video to edit will be open faster and dont increse app folder size.
yes, you are right I tried to open a video with a size of 1Gb two times and the app size became 2gb. It needs to be fixed. I'll try to find the workaround
As fast solution it's remove original video from app folder after edit and save only edited video. But this is not resolve long time copy original video
@onaburalnyionseo Can you try this implementation 'com.github.a914-gowtham:Android-video-trimmer:83d2302d57'
. In this snapshot CopiedVideoFile is deleted in onDestroy of the ActTrimmer .
If it works for you. I can make a release(1.7.0) with this fix and #49 fix
I have found a way to avoid doing copyToInternalStorage. So, there will be no needed to show progress. It will be available in the 1.7.1 version.
@onaburalnyionseo You will need this. I made a breaking change.
//create a global variable
ActivityResultLauncher<Intent> videoTrimResultLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
if (result.getResultCode() == Activity.RESULT_OK &&
result.getData() != null) {
Uri uri = Uri.parse(TrimVideo.getTrimmedVideoPath(result.getData()));
Log.d(TAG, "Trimmed path:: " + uri);
} else
LogMessage.v("videoTrimResultLauncher data is null");
});
TrimVideo.activity(data)
.setCompressOption(new CompressOption()) //pass empty constructor for default compress option
.start(this, videoTrimResultLauncher);
//for Kotlin
val startForResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
result: ActivityResult ->
if (result.resultCode == Activity.RESULT_OK) {
//handle data
}
}
TrimVideo.activity(data)
.setCompressOption(new CompressOption()) //pass empty constructor for default compress option
.start(this, videoTrimResultLauncher)
@a914-gowtham Hi. yes its work, you can release this change to 1.7.0 but i think i still be wait your improvement ASAP. it
s about:
"I have found a way to avoid doing copyToInternalStorage. So, there will be no needed to show progress.
It will be available in the 1.7.1 version."
@onaburalnyionseo I just made releases 1.7.0 and 1.7.1
implementation 'com.github.a914-gowtham:android-video-trimmer:1.7.1'
I call: TrimVideo.activity(String.valueOf(data.getData())) .setTrimType(TrimType.MIN_MAX_DURATION) .setMinToMax(5, 60).start(fragment);
after that my UI is freeze. in profiler i found that copyFileToInternalStorage() in method setDataInView() in ActVideoTrimmer.onPostCreate need do in background thread because it freeze UI Thread.
i think the best solution its dont copy video on start and save only cropped part to app folder.