Tuesday, November 26, 2013

JavaCV Tutorial 3 -Video Recording



In this tutorial I've explained the process of recording a video from the Webcam with different resolutions and with different formats.
Setting different Resolutions :
" cvSetCaptureProperty(capture1,CV_CAP_PROP_FRAME_WIDTH,Wd);
        cvSetCaptureProperty(capture1,CV_CAP_PROP_FRAME_HEIGHT,Ht); "

" FrameRecorder recorder1 = new OpenCVFrameRecorder("RecordVid.avi",Wt , Ht); "

"Wd = 1920;1280;720;640;320;
  Ht = 1080;720;480;360;240; "

 Setting Different Codecs :
For MJPG: "  recorder1.setVideoCodec(CV_FOURCC('M','J','P','G')); "
For DIVX: "  recorder1.setVideoCodec(CV_FOURCC('D','I','V','X')); " 
For MP4V: "  recorder1.setVideoCodec(CV_FOURCC('M','P','4','V')); "

Source Code: " https://drive.google.com/file/d/0Bxr1St4kFOnQcDFZRWczc0xwR3c/edit?usp=sharing "





14 comments:

  1. I'm getting an error in this line->> recorder1.setVideoCodec(CV_FOURCC('M','J','P','G'));
    Saying that "incompatible types: possible lossy conversion from char to byte".
    I'm using netbeans 8.0.2 IDE.
    Please suggest me appropriate modification.

    ReplyDelete
    Replies
    1. hey have u tried to import ffmpeg files into your project ... or try it out with some different codec settings as -- " recorder1.setVideoCodec(CV_FOURCC('D','I','V','X')); ,
      recorder1.setVideoCodec(CV_FOURCC('M','P','4','V')); "

      Delete
    2. or ... try this one instead ' recorder1.setCodecID(CV_FOURCC('M','J','P','G')); '

      Delete
    3. or u can try another one like this ' recorder1.setFormat("mp4"); '

      Delete
  2. I have imported the ffmpeg files, I used all suggestions made by you but result is still same. It's showing an error saying.... incompatible types: possible lossy conversion from char to byte".

    ReplyDelete
  3. recorder1.setFormat("mp4"); I used this code, it worked. Thanks a lot. The single problem is that as close my video capturing window it starts again automatically.

    ReplyDelete
  4. After recording when i play the recorded video it prompts that.... Windows Media Player cannot play the file. The Player might not support the file type or might not support the codec that was used to compress the file. How to cope up with it?

    ReplyDelete
  5. Thank you for such an amazing video tutorial.
    I want to capture video at specific time interval repeatedly. how can i perform that??
    can you help me ...

    ReplyDelete
  6. i am getting an error in recorder1.record(img1).
    Error is IplImage cannot be converted to frame

    ReplyDelete
  7. i am getting an error in recorder1.record(img1).
    Error is IplImage cannot be converted to frame

    ReplyDelete
  8. please reply i have been waiting for the reply

    ReplyDelete
  9. I also having problem with recorder1.record(img1)

    ReplyDelete