AndroidDeveloperLB / VideoTrimmer

Allows to trim videos on Android, including UI
MIT License
147 stars 25 forks source link

Force Close on setVideo() #3

Closed PGMacDesign closed 5 years ago

PGMacDesign commented 5 years ago

When I set the video Uri to match the one I just took via the path:

trim_video_trimmer_view.setVideo(Uri.parse(videoFile.getPath()));

I see this error:

    java.lang.IllegalArgumentException
        at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:172)
        at com.lb.video_trimmer_library.view.TimeLineView$getBitmap$1.execute(TimeLineView.kt:74)
        at com.lb.video_trimmer_library.utils.BackgroundExecutor$Task.run(BackgroundExecutor.kt:200)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
AndroidDeveloperLB commented 5 years ago

Check the sample please. It uses a Uri as you should.

PGMacDesign commented 5 years ago

To anyone who comes across this in the future, the problem was that the input needs the absolute path. The solution was to use the Uri.fromFile(file); method instead of the Uri.parse(path); method. The Uri for each of them looks like this:

(From File) -- file:///storage/emulated/0/Android/data/my.app/files/Movies/2019-04-25-09%3A10%3A28.mp4

(From Path) -- /storage/emulated/0/Android/data/my.app/files/Movies/2019-04-25-09:10:28.mp4

AndroidDeveloperLB commented 5 years ago

Oh I think I had this issue in the past too.