2

I am trying to save this video and getting this error.

i have added two jar file 1) javacv 2) javacpp

and for camera preview i have used opencv.

here i am adding code.

` 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;
        }`

and i am getting this error..

11-20 13:47:09.349: ERROR/AndroidRuntime(4954): FATAL EXCEPTION: main 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): at android.view.View.performClick(View.java:2485) 11-20 13:47:09.349: ERROR/AndroidRuntime(4954): at android.view.View$PerformClick.run(View.java:9080) 11-20 13:47:09.349: ERROR/AndroidRuntime(4954): at android.os.Handler.handleCallback(Handler.java:587) 11-20 13:47:09.349: ERROR/AndroidRuntime(4954): at android.os.Handler.dispatchMessage(Handler.java:92) 11-20 13:47:09.349: ERROR/AndroidRuntime(4954): at android.os.Looper.loop(Looper.java:130) 11-20 13:47:09.349: ERROR/AndroidRuntime(4954): at 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): Caused by: 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 more 11-20 13:47:09.349: ERROR/AndroidRuntime(4954): Caused by: 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 more 11-20 13:47:09.349: ERROR/AndroidRuntime(4954): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jniavutil: findLibrary returned 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 more

can anyone help me out on this..

4

0 回答 0