sourab-sharma / TouchToRecord

Touch android camera surface view to record video using FFmpeg Recorder
297 stars 104 forks source link

App crash while start video recording #9

Closed sdubey0201 closed 8 years ago

sdubey0201 commented 9 years ago

Hi sourab

i have tried to use this to my project camera started nicely once i touch camera surface view it got crash

due to some java.nio.BufferOverflowException

Logs i have found in logcat

FATAL EXCEPTION: main Process: com.sourab.touch.to.record.demo, PID: 3232 java.nio.BufferOverflowException at java.nio.Buffer.checkPutBounds(Buffer.java:183) at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:356) at java.nio.ByteBuffer.put(ByteBuffer.java:721) at com.javacv.recorder.FFmpegRecorderActivity$CameraView.onPreviewFrame(FFmpegRecorderActivity.java:614) at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1112) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5312) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)

jonasborggren commented 9 years ago

I get the same error.

tosslife commented 9 years ago

error +1

xmonfort commented 9 years ago

I get the same error

itlonewolf commented 9 years ago

I got this error

06-02 09:21:36.860  16004-16004/com.sourab.touch.to.record.demo E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.sourab.touch.to.record.demo, PID: 16004
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sourab.touch.to.record.demo/com.javacv.recorder.FFmpegRecorderActivity}: java.lang.RuntimeException: setParameters failed
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
     Caused by: java.lang.RuntimeException: setParameters failed
            at android.hardware.Camera.native_setParameters(Native Method)
            at android.hardware.Camera.setParameters(Camera.java:1876)
            at com.javacv.recorder.FFmpegRecorderActivity.handleSurfaceChanged(FFmpegRecorderActivity.java:728)
            at com.javacv.recorder.FFmpegRecorderActivity.initCameraLayout(FFmpegRecorderActivity.java:260)
            at com.javacv.recorder.FFmpegRecorderActivity.initLayout(FFmpegRecorderActivity.java:249)
            at com.javacv.recorder.FFmpegRecorderActivity.onCreate(FFmpegRecorderActivity.java:176)
            at android.app.Activity.performCreate(Activity.java:5990)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
ravipatel26 commented 9 years ago

@itlonewolf

I resolved the issue you are having by commenting out line 713 in JavaCvVideoRecorder/src/com/javacv/recorder/FFmpegRecorderActivity.java

Here this library was trying to manually set the FPS for the video. That is no longer required. This solution worked for me.

Hope this helps.

workpanda commented 9 years ago

I found error. I can't merge with video and audio now.

return (new Processor(getEncodingLibraryPath(paramContext), paramContext)).newCommand().addInputPath(mCurrentVideoOutput).addInputPath(mAudioFilename).setMap("0:0").setMap("1:0").setCopy().setMetaData(getMetaData()).enableOverwrite().processToOutput(mOutput);

if you have any suggestion, please help me.

szitguy commented 8 years ago

@workpanda Do u fix it ? I got the same problem too

szitguy commented 8 years ago

@workpanda I fixed my problem just now. I use Camera.setPreviewCallbackWithBuffer() method instead of the original Camera.setPreviewCallback() in this library.However, i forgot to call Camera.addCallbackBuffer(byte[]) at the end of the PreviewCallback.onPreviewFrame() method that caused the video data was recorded only one frame. So, i guess recorded video data is much less than the recorded audio data(audio data is collected by the native AudioRecord),.Then, ffmepg can not combine the two "unmatchable" data source.

sourab-sharma commented 8 years ago

Please try updated code.