Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Video writer in java not saving

Hello all,

I want to record the frames I'm processing in my android smarthpone but nothing is being saved. I'm not getting any error either...

First I created the object in the MainActivity:

private VideoWriter videoWriter;

In the method onCreate I've initialized it and opened

    videoWriter = new VideoWriter("saved_video.avi", VideoWriter.fourcc('m','j','p','g'),
            25.0D, new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));
    videoWriter.open("saved_video.avi", VideoWriter.fourcc('m','j','p','g'),
            25.0D,  new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));

In the method onCameraFrame I've put the following

    if(!videoWriter.isOpened()){
        Log.w("opened video", "OPENED");
        videoWriter.open("saved_video.avi", VideoWriter.fourcc('m','j','p','g'),
                25.0D,  new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));
        videoWriter.write(frame);
    } else if(frameCounter<50) {
        videoWriter.write(frame);
        Log.w("saved frame", "SAVED");
    }
    }

Every frame I run returns videoWriter.isOpened()==false. I'm not using any ".release" method because I didn't know where to put it.

Thanks in advance!

Video writer in java not saving

Hello all,

I want to record the frames I'm processing in my android smarthpone but nothing is being saved. I'm not getting any error either...

First I created the object in the MainActivity:

private VideoWriter videoWriter;

In the method onCreate I've initialized it and opened

    videoWriter = new VideoWriter("saved_video.avi", VideoWriter.fourcc('m','j','p','g'),
VideoWriter.fourcc('M','J','P','G'),
            25.0D, new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));
    videoWriter.open("saved_video.avi", VideoWriter.fourcc('m','j','p','g'),
VideoWriter.fourcc('M','J','P','G'),
            25.0D,  new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));

In the method onCameraFrame I've put the following

    if(!videoWriter.isOpened()){
        Log.w("opened video", "OPENED");
        videoWriter.open("saved_video.avi", VideoWriter.fourcc('m','j','p','g'),
VideoWriter.fourcc('M','J','P','G'),
                25.0D,  new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));
        videoWriter.write(frame);
    } else if(frameCounter<50) {
        videoWriter.write(frame);
        Log.w("saved frame", "SAVED");
    }
    }

Every frame I run returns videoWriter.isOpened()==false. I'm not using any ".release" method because I didn't know where to put it.

Thanks in advance!


EDIT:

Hello berak,

(1) thanks, (2) isOpened() is returning false (3) I was hoping it would simply save it to the smartphone root. Previously I've tried to save it to the download folder "/Phone/Download/saved_video.avi" (4) I had 'M' 'J' 'P' 'G' first and it didn't work. Later I found a solution that someone was using 'm' 'j' 'p' 'g', decided to try it also and forgot to switch it back to MJPG. (edited the Question)

(wrote it here because I can't post an answer until tomorrow)

Video writer in java not saving

Hello all,

I want to record the frames I'm processing in my android smarthpone but nothing is being saved. I'm not getting any error either...

First I created the object in the MainActivity:

private VideoWriter videoWriter;

In the method onCreate I've initialized it and opened

    videoWriter = new VideoWriter("saved_video.avi", VideoWriter.fourcc('M','J','P','G'),
            25.0D, new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));
    videoWriter.open("saved_video.avi", VideoWriter.fourcc('M','J','P','G'),
            25.0D,  new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));

In the method onCameraFrame I've put the following

    if(!videoWriter.isOpened()){
        Log.w("opened video", "OPENED");
        videoWriter.open("saved_video.avi", VideoWriter.fourcc('M','J','P','G'),
                25.0D,  new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));
        videoWriter.write(frame);
    } else if(frameCounter<50) {
        videoWriter.write(frame);
        Log.w("saved frame", "SAVED");
    }
    }

Every frame I run returns videoWriter.isOpened()==false. I'm not using any ".release" method because I didn't know where to put it.

Thanks in advance!


EDIT:

Hello berak,

(1) thanks, (2) isOpened() is returning false (3) I was hoping it would simply save it to the smartphone root. Previously I've tried to save it to the download folder "/Phone/Download/saved_video.avi" (4) I had 'M' 'J' 'P' 'G' first and it didn't work. Later I found a solution that someone was using 'm' 'j' 'p' 'g', decided to try it also and forgot to switch it back to MJPG. (edited the Question)

(wrote it here because I can't post an answer until tomorrow)