我正在尝试保存此视频并收到此错误消息。
我添加了两个jar文件 1)javacv 2)javacpp
对于相机预览,我使用了 opencv 。
这里我正在添加代码。
`public void run(){
while (true) {
Bitmap bmp = null;
synchronized (this) {
if (mCamera == null)
break;
if (!mCamera.grab()) {
Log.e(TAG, "mCamera.grab() failed");
break;
}
bmp = processFrame(mCamera);
if(isRecording)
{
ByteBuffer buffer = ByteBuffer.allocate(bmp.getRowBytes()*bmp.getHeight());
bmp.copyPixelsFromBuffer(buffer);
try {
recorder.record(buffer);
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (bmp != null) {
Canvas canvas = mHolder.lockCanvas();
if (canvas != null)
{
Matrix matrix = new Matrix();
matrix.preTranslate((canvas.getWidth() - getFrameWidth())/2, (canvas.getHeight() - getFrameHeight())/2);
if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
matrix.postRotate(90f,(canvas.getWidth()) / 2,(canvas.getHeight()) / 2);
canvas.drawBitmap(bmp, matrix, new Paint());
mHolder.unlockCanvasAndPost(canvas);
}
bmp.recycle();
}
}
Log.i(TAG, "Finishing processing thread");
}
// For Recording File
public boolean prepareVideoRecorder()
{
recorder = new FFmpegFrameRecorder(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString(), getFrameWidth(), getFrameHeight());
recorder.setVideoCodec(avcodec.AV_CODEC_ID_MJPEG);
recorder.setPixelFormat(avutil.PIX_FMT_YUV420P);
recorder.setAudioCodec(avcodec.AV_CODEC_ID_PCM_S16LE);
try {
recorder.start();
} catch (Exception e)
{
return false;
}
return true;
}`
我收到了这个错误..
11-20 13:47:09.349:ERROR / AndroidRuntime(4954):致命异常:主要 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):java.lang.ExceptionInInitializerError 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacv.FFmpegFrameRecorder。(FFmpegFrameRecorder.java:119) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacv.FFmpegFrameRecorder。(FFmpegFrameRecorder.java:112) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.boomalaya.moovix.CameraPreview $ Preview.prepareVideoRecorder(CameraPreview.java:454) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.boomalaya.moovix.CameraPreview $ 2.onClick(CameraPreview.java:172) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):在android.view.View.performClick(View.java:2485) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):在android.view.View $ PerformClick.run(View.java:9080) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):在android.os.Handler.handleCallback(Handler.java:587) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):在android.os.Handler.dispatchMessage(Handler.java:92) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):在android.os.Looper.loop(Looper.java:130) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):在android.app.ActivityThread.main(ActivityThread.java:3687) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at java.lang.reflect.Method.invokeNative(Native Method) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at java.lang.reflect.Method.invoke(Method.java:507) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:867) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at dalvik.system.NativeStart.main(Native Method) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):引起:java.lang.ExceptionInInitializerError 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at java.lang.Class.classForName(Native Method) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at java.lang.Class.forName(Class.java:234) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacpp.Loader.load(Loader.java:338) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacv.cpp.avformat。(avformat.java:76) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):......还有15个 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):引起:java.lang.ExceptionInInitializerError 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at java.lang.Class.classForName(Native Method) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at java.lang.Class.forName(Class.java:234) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacpp.Loader.load(Loader.java:338) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacv.cpp.avcodec。(avcodec.java:86) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):......还有19个 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):引起:java.lang.UnsatisfiedLinkError:无法加载jniavutil:findLibrary返回null 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at java.lang.Runtime.loadLibrary(Runtime.java:429) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at java.lang.System.loadLibrary(System.java:554) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:448) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacpp.Loader.load(Loader.java:372) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacpp.Loader.load(Loader.java:319) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):at com.googlecode.javacv.cpp.avutil。(avutil.java:75) 11-20 13:47:09.349:ERROR / AndroidRuntime(4954):... 23更多
任何人都可以帮我解决这个问题..