ffmpeg-android-java icon indicating copy to clipboard operation
ffmpeg-android-java copied to clipboard

Handling Multiple Commands

Open robinonsay opened this issue 8 years ago • 13 comments

I'm trimming mp4 files and noticed if I ran another command while one was running, I get this error.

com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException: FFmpeg command is already running, you are only allowed to run single command at a time
      at com.github.hiteshsondhi88.libffmpeg.FFmpeg.execute(FFmpeg.java:66)
      at com.github.hiteshsondhi88.libffmpeg.FFmpeg.execute(FFmpeg.java:79)
      at drivespotter.com.continuousrecordcam.api.s3.S3MediaAPI.sendMediaSegment(S3MediaAPI.java:55)
      at drivespotter.com.continuousrecordcam.ContinuousRecordActivity.stopRecorder(ContinuousRecordActivity.java:199)
      at drivespotter.com.continuousrecordcam.ContinuousRecordActivity.access$200(ContinuousRecordActivity.java:41)
      at drivespotter.com.continuousrecordcam.ContinuousRecordActivity$2.onClick(ContinuousRecordActivity.java:171)
      at android.view.View.performClick(View.java:4466)
      at android.view.View$PerformClick.run(View.java:18542)
      at android.os.Handler.handleCallback(Handler.java:733)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:136)
      at android.app.ActivityThread.main(ActivityThread.java:5097)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
      at dalvik.system.NativeStart.main(Native Method)

I would think that because it is running on a separate thread it would be fine. What is the recommended way to run multiple commands?

robinonsay avatar Jul 09 '16 15:07 robinonsay

Have you resolved this issue?

HD-AD avatar Aug 21 '17 11:08 HD-AD

No, I have not

robinonsay avatar Aug 21 '17 12:08 robinonsay

I've been using this library for over a year too and haven't found any workaround for this, the library manages threading (or rather the lack thereof) on it's own, so calling execute() from another thread is of no use.

My suggestion: Manage your own 'pool' of commands. A simple queue of tasks that you do one after another. This way you can move up the elements in onFinish() and simply append to the queue whenever another task comes up and they'll get done one by one.

Aditya94A avatar Aug 21 '17 13:08 Aditya94A

@AdityaAnand1 My issue is that I get this error "FFmpeg command is already running" even after the command is done. I can't run a command one after the other?

HD-AD avatar Aug 24 '17 05:08 HD-AD

@HD-AD That's weird. Are you absolutely certain you're waiting for onFinish() before firing off the second command?

Are you able to run multiple commands using the sample apk?

Aditya94A avatar Aug 26 '17 04:08 Aditya94A

@AdityaAnand1 yes I'm sure the command completes in onFinish(). The processing I do doesn't take long so I haven't tried running multiple commands as the command doesn't take long to finish. At the moment I have to destroy the application/activity in order to run a new command. I don't know if the issue could be because I'm calling loadFFmpeg() in onCreate(), but the example does the same, this is a big issue for my application so I really hope someone can help me out. Thanks for taking the time to reply.

HD-AD avatar Aug 26 '17 05:08 HD-AD

@AdityaAnand1 I can also downvote, I'm asking for help, no need to be an ass!

HD-AD avatar Aug 28 '17 06:08 HD-AD

The last task was left unfinished。

lessismore100 avatar Sep 20 '17 12:09 lessismore100

@steveLYL yes I got it working, thank you for answering.

HD-AD avatar Sep 20 '17 12:09 HD-AD

@HD-AD very good.

lessismore100 avatar Sep 26 '17 08:09 lessismore100

trying to mFFmpeg.killRunningProcesses()

wapchief avatar Feb 28 '18 10:02 wapchief

mFFmpeg.killRunningProcesses() 这个不起作用

duwurensheng010 avatar Jun 21 '18 02:06 duwurensheng010

but I don't want to kill my running progress.

SwapnilNSDN avatar May 03 '19 11:05 SwapnilNSDN