keke77 / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Unable to record video #293

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi 

Below iam attaching the code 

import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.FFmpegFrameRecorder;
import com.googlecode.javacv.FrameGrabber;
import com.googlecode.javacv.FrameRecorder.Exception;
import com.googlecode.javacv.OpenCVFrameGrabber;
import com.googlecode.javacv.VideoInputFrameGrabber;
import com.googlecode.javacv.cpp.avutil;
import com.googlecode.javacv.cpp.opencv_core.IplImage;

public class CameraTest {

    /**
     * @param args
     */
    public static final String FILENAME = "C:\\Users\\LENOVO\\Pictures\\output.mp4";
    public static void main(String[] args)  {
        try{
            FrameGrabber grabber = new VideoInputFrameGrabber(0);

        grabber.start();
        IplImage grabbedImage = grabber.grab();

        CanvasFrame canvasFrame = new CanvasFrame("Cam");
        canvasFrame.setCanvasSize(grabbedImage.width(), grabbedImage.height());

        System.out.println("framerate = " + grabber.getFrameRate());

        FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(FILENAME,  grabber.getImageWidth(),grabber.getImageHeight());
        grabber.setFrameRate(grabber.getFrameRate());
        recorder.setVideoCodec(13);
        recorder.setFormat("flv");
        recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
        recorder.setFrameRate(30);
        recorder.setVideoBitrate(10 * 1024 * 1024);

        recorder.start();
        while (canvasFrame.isVisible() && (grabbedImage = grabber.grab()) != null) {
            canvasFrame.showImage(grabbedImage);
            recorder.record(grabbedImage);
        }
        recorder.stop();
        grabber.stop();
        canvasFrame.dispose();
        }catch(Exception e){
            e.printStackTrace();
        } catch (com.googlecode.javacv.FrameGrabber.Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

Iam getting output as 

framerate = 0.0
Execution protection violation
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00905a4d, pid=3468, tid=1784
#
# JRE version: 7.0_10-b18
# Java VM: Java HotSpot(TM) Client VM (23.6-b04 mixed mode windows-x86 )
# Problematic frame:
# C  0x00905a4d
#
# Failed to write core dump. Minidumps are not enabled by default on client 
versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\LENOVO\workspace\JavaCV\JavaCV\hs_err_pid3468.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****

SETUP: Setting up device 0
SETUP: Lenovo EasyCamera
SETUP: Couldn't find preview pin using SmartTee
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.

I followed below link, but unable to fix the issue even after placing the 
updated jars in classpath.
https://code.google.com/p/javacv/issues/detail?id=291

Please let me know how to fix it?

Thanks,
Damodar.

Original issue reported on code.google.com by damuchi...@gmail.com on 11 Mar 2013 at 6:09

GoogleCodeExporter commented 9 years ago
Does the Demo class found in the README.txt work correctly?

Original comment by samuel.a...@gmail.com on 11 Mar 2013 at 6:58

GoogleCodeExporter commented 9 years ago

Thanks for replay...

In the JavaCV which i downloaded unable to find this file 
haarcascade_frontalface_alt.xml. Please can you provide this file

Original comment by damuchi...@gmail.com on 11 Mar 2013 at 7:06

GoogleCodeExporter commented 9 years ago
https://raw.github.com/Itseez/opencv/master/data/haarcascades/haarcascade_fronta
lface_alt.xml

Original comment by samuel.a...@gmail.com on 11 Mar 2013 at 7:11

GoogleCodeExporter commented 9 years ago
after using above xml, iam getting below exception

Exception in thread "main" com.googlecode.javacv.FrameGrabber$Exception: 
videoInput.getPixels() Error: Could not get pixels.
    at com.googlecode.javacv.VideoInputFrameGrabber.grab(VideoInputFrameGrabber.java:168)
    at Demo.main(Demo.java:43)

VIDEOINPUT SPY MODE!

SETUP: Looking For Capture Devices
SETUP: 0) Lenovo EasyCamera 
SETUP: 1 Device(s) found

***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****

SETUP: Setting up device 0
SETUP: Lenovo EasyCamera
SETUP: Couldn't find preview pin using SmartTee
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.

Original comment by damuchi...@gmail.com on 11 Mar 2013 at 7:18

GoogleCodeExporter commented 9 years ago
try to replace `FrameGrabber.createDefault(0)` with `new OpenCVFrameGrabber(0)`

Original comment by samuel.a...@gmail.com on 11 Mar 2013 at 7:27

GoogleCodeExporter commented 9 years ago
Now iam getting below error
Execution protection violation
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00905a4d, pid=7072, tid=7448
#
# JRE version: 7.0_10-b18
# Java VM: Java HotSpot(TM) Client VM (23.6-b04 mixed mode windows-x86 )
# Problematic frame:
# C  0x00905a4d
#
# Failed to write core dump. Minidumps are not enabled by default on client 
versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\LENOVO\workspace\JavaCV\JavaCV\hs_err_pid7072.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Original comment by damuchi...@gmail.com on 11 Mar 2013 at 7:36

Attachments:

GoogleCodeExporter commented 9 years ago
This has been fixed with issue #291. You're mixing up some files here.

Original comment by samuel.a...@gmail.com on 11 Mar 2013 at 7:47

GoogleCodeExporter commented 9 years ago
can you please check, my beginning of the post, u can see i followed that issue 
#291 and replaced the jars u provided from that issue. Even after iam getting 
this issue.

Original comment by damuchi...@gmail.com on 11 Mar 2013 at 7:50

GoogleCodeExporter commented 9 years ago
Well, it works fine here, so I can't fix something that works fine with my 
machine. If you figure out why this is happening on your machine, please let me 
know so I can fix it, thank you.

Original comment by samuel.a...@gmail.com on 11 Mar 2013 at 7:54