Greetings. I am working on a Unity project that uses vuforia for AR tracking. At some point, I need to use ffmpeg to generate an image sequence from an existing video file. For some reason, after calling ffmpeg and generating the images - when I start vuforia back up, the app crashes without any information on what caused the crash. Please note ffmpeg successfully generates the images. By commenting out the call to ffmpeg, I can avoid the crash entirely.
Any ideas? Below is the process that runs ffmpeg.
I start with an android java class in Unity:
AndroidJavaClass _link = new AndroidJavaClass("com.example.package.Encoder"); _link.CallStatic("startEncode");
Above I call "startEncode" - defined in class, "Encoder":
public class Encoder { private static Thread encoder_thread; public static void startEncode() { VideoProcessor r = new VideoProcessor(); encoder_thread = new Thread(r); encoder_thread.setPriority(Thread.MAX_PRIORITY); encoder_thread.start(); } }
The VideoProcessor thread makes the call to ffmpeg:
public class VideoProcessor implements Runnable{ private Invokerffmpeg _inv = new Invokerffmpeg(); @Override public void run() { try { String[] ffmpeg_command = { "ffmpeg", "-i", effectSource, "-f", "image2", "-vcodec", "png", outPath }; _inv.run(ffmpegLocation, ffmpeg_command); // commenting this line out will prevent the crash } catch(Exception e) { Log.e(TAG, "FFMPEG Error", e);} } // >> code to dispatch complete message back to Unity << }
The "_inv" member is defined here:
public class Invokerffmpeg { static{ System.loadLibrary("ffmpeginvoke");} public native void run(String path_ffmpeg_lib,String[] args); }
Thanks in advance for any help!
Hi, as vincekilian said, there is a chance that the access to the camera might interfere with the QCAR process also accessing the camera.
At the moment we don't know of a viable solution or workaround of this issue.