Closed DaniilGalahov closed 3 years ago
I'm not very familiar with Unity. So, I don't know what is wrong there.
But, I see that you use AndroidJNI.AttachCurrentThread();
methods. Are you sure you need these calls? I had tested some parts of Using MobileFFmpeg in Unity guide and didn't have to use them.
AndroidJNI.AttachCurrentThread();
is required, because I using calls from other thread (for prevent Unity freezing while ffmpeg performs long operations).
int result = ffmpeg.CallStatic<int>("execute", new object[] { arguments });
works fine. Only executeAsync
and cancel
not working from Unity.
Also, after last tests I found this error in logcat: E Unity : AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='cancel' signature='()I' in class Lcom.arthenica.mobileffmpeg.FFmpeg;
AndroidJNI.AttachCurrentThread(); is required, because I using calls from other thread (for prevent Unity freezing while ffmpeg performs long operations).
Okay. But, if you want to prevent freezing you should be running ffmpeg commands in another thread. AndroidJNI.AttachCurrentThread()
doesn't create another thread for you. You are still in the same one. I'm not convinced that this is necessary. Your reason might be valid but your solution, using AndroidJNI.AttachCurrentThread(), is not relevant to your reason.
AndroidJNI.AttachCurrentThread()
doesn't create another thread for you. You are still in the same one. I'm not convinced that this is necessary.
It's necessary, in my architecture. But, anyway, even if I remove it and call my methods CallFFMPEGAsync()
or StopFFMPEG()
from main thread (for test purposes), mobile-ffmpeg isn't worked and I've got in logcat this error messages:
E Unity : AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='executeAsync' signature='(Ljava/lang/String;)I' in class Lcom.arthenica.mobileffmpeg.FFmpeg;
E Unity : java.lang.NoSuchMethodError: no static method with name='executeAsync' signature='(Ljava/lang/String;)I' in class Lcom.arthenica.mobileffmpeg.FFmpeg;
and
E Unity : AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='cancel' signature='()I' in class Lcom.arthenica.mobileffmpeg.FFmpeg;
E Unity : java.lang.NoSuchMethodError: no static method with name='cancel' signature='()I' in class Lcom.arthenica.mobileffmpeg.FFmpeg;
I.e., looks like executeAsync
and cancel
are not accessible.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm trying to use mobile-ffmpeg with Unity for recording video from device camera. I need to start video recording by command from parent Unity app, and then stop it by other command. To do this I'm using this code:
Arguments contains almost the same as in your example on the main page:
But it just doesn't work. App crashing if I try to call CallFFMPEGAsync() or even StopFFMPEG(), without any error reports in logcat.
My environment is:
Please, tell me how to solve this.