a914-gowtham / android-video-trimmer

Helps to trim local videos with compress option on Android applications using Exoplayer 2 and FFmpeg.
Other
372 stars 117 forks source link

Video is showing up black and unable to play when starting activity and passing in videoURI string #13

Closed seanfriedman1994 closed 4 years ago

seanfriedman1994 commented 4 years ago

Here is a snip of my code. trim is a button that is clicked that triggers the new activity.

trim.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TrimVideo.activity(String.valueOf(mVideoUri)) // .setCompressOption(new CompressOption()) //empty constructor for default compress option .setDestination("/storage/emulated/0/DCIM/TESTFOLDER") //default output path /storage/emulated/0/DOWNLOADS .start(getActivity());

        }
    });

Here is an image of what it looks like, and the play button does nothing

Capture

a914-gowtham commented 4 years ago

Videouri might have been null.Can you share the error log

seanfriedman1994 commented 4 years ago

2020-09-21 18:35:00.225 11942-11942/com.dev.sporsightmobile D/uri: /storage/emulated/0/Pictures/SporSight/Recordings/VID_07_08_20_22_21_01.mp4 2020-09-21 18:35:00.240 11942-11942/com.dev.sporsightmobile I/ExoPlayerImpl: Release 323eb12 [ExoPlayerLib/2.11.8] [generic_x86, Android SDK built for x86, Google, 29] [goog.exo.core, goog.exo.ui] 2020-09-21 18:35:00.258 11942-12060/com.dev.sporsightmobile D/SurfaceUtils: disconnecting from surface 0xc9e33808, reason disconnectFromSurface 2020-09-21 18:35:00.284 11942-11942/com.dev.sporsightmobile W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@91ef464 2020-09-21 18:35:00.413 11942-11942/com.dev.sporsightmobile I/ExoPlayerImpl: Init 1b2b0b5 [ExoPlayerLib/2.11.8] [generic_x86, Android SDK built for x86, Google, 29] 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: java.lang.NullPointerException: uriString 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: at android.net.Uri$StringUri.(Uri.java:496) 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: at android.net.Uri$StringUri.(Uri.java:486) 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: at android.net.Uri.parse(Uri.java:458) 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: at com.gowtham.library.ui.ActVideoTrimmer.setDataInView(ActVideoTrimmer.java:179) 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: at com.gowtham.library.ui.ActVideoTrimmer.onPostCreate(ActVideoTrimmer.java:149) 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1373) 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3321) 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221) 2020-09-21 18:35:00.420 11942-11942/com.dev.sporsightmobile W/System.err: at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201) 2020-09-21 18:35:00.421 11942-11942/com.dev.sporsightmobile W/System.err: at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173) 2020-09-21 18:35:00.421 11942-11942/com.dev.sporsightmobile W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 2020-09-21 18:35:00.421 11942-11942/com.dev.sporsightmobile W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 2020-09-21 18:35:00.421 11942-11942/com.dev.sporsightmobile W/System.err: at android.os.Handler.dispatchMessage(Handler.java:107) 2020-09-21 18:35:00.421 11942-11942/com.dev.sporsightmobile W/System.err: at android.os.Looper.loop(Looper.java:214) 2020-09-21 18:35:00.421 11942-11942/com.dev.sporsightmobile W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7356) 2020-09-21 18:35:00.421 11942-11942/com.dev.sporsightmobile W/System.err: at java.lang.reflect.Method.invoke(Native Method) 2020-09-21 18:35:00.421 11942-11942/com.dev.sporsightmobile W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 2020-09-21 18:35:00.421 11942-11942/com.dev.sporsightmobile W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 2020-09-21 18:35:00.478 11942-11999/com.dev.sporsightmobile D/EGL_emulation: eglMakeCurrent: 0xe181a780: ver 2 0 (tinfo 0xe180f900)

Looks like you're correct. The very first line is a log of the videouri.ToString() so I don't understand how it can be passing through as null

seanfriedman1994 commented 4 years ago

Code for the above looks like this:

public void onClick(View v) { Log.d("uri", mVideoUri.toString()); TrimVideo.activity(mVideoUri.toString()) // .setCompressOption(new CompressOption()) //empty constructor for default compress option .setDestination("/storage/emulated/0/DCIM/TESTFOLDER") .start(getActivity());

        }
a914-gowtham commented 4 years ago

I got you.Send Uri of the video instead of FilePath.like below

String selectedVideoUri="content://com.android.providers.media.documents/document/video%3A3120"
TrimVideo.activity(selectedVideoUri)
// .setCompressOption(new CompressOption()) //empty constructor for default compress option
.setDestination("/storage/emulated/0/DCIM/TESTFOLDER")
.start(getActivity());
seanfriedman1994 commented 4 years ago

Thank you man that did the trick. One more question for you if you don't mind - how can i name the file what i want? I can set the directory but it's always named trimmed_video_0

a914-gowtham commented 4 years ago

Sorry..I have not added that option yet.I will add for next release

seanfriedman1994 commented 4 years ago

I see. Thank you very much, I look forward to that release!