chrisnp / javacv

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

how to put audio video javacv? #485

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello, I'm new to javacv my code to capture and video recording of the running, 
but does not save audio, if someone could solve my problem, I would be very 
grateful, thanks

import com.googlecode.javacv.FFmpegFrameGrabber;
import com.googlecode.javacv.FrameRecorder;
import com.googlecode.javacv.FrameRecorder.Exception;
import com.googlecode.javacv.OpenCVFrameRecorder;
import static com.googlecode.javacv.cpp.opencv_core.*;
import com.googlecode.javacv.cpp.opencv_core.CvScalar;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import com.googlecode.javacv.cpp.opencv_highgui.CvCapture;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
public class JavaCv3 {

    /**
     * @param args
     * @throws Exception 
     */
    public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub

        CvCapture capture1 = cvCreateCameraCapture(CV_CAP_ANY);
        cvSetCaptureProperty(capture1,CV_CAP_PROP_FRAME_WIDTH,640);
        cvSetCaptureProperty(capture1,CV_CAP_PROP_FRAME_HEIGHT,480);

        cvNamedWindow("LiveVid",CV_WINDOW_AUTOSIZE);

        FrameRecorder recorder1 = new OpenCVFrameRecorder("Video.avi",640,480);
        recorder1.setVideoCodec(CV_FOURCC('M','J','P','G'));
        recorder1.setFrameRate(15);
        recorder1.setPixelFormat(1);
        recorder1.start();

        IplImage img1;

        for(;;){

            img1 = cvQueryFrame(capture1);

            if(img1==null) break;

            cvShowImage("LiveVid",img1);
            recorder1.record(img1);

            char c = (char) cvWaitKey(15);
            if(c == 'q') break;

        }

        recorder1.stop();
        cvDestroyWindow("LiveVid");
        cvReleaseCapture(capture1);
        }
}

S.O.S.

Original issue reported on code.google.com by linojuar...@gmail.com on 1 Oct 2014 at 10:17

GoogleCodeExporter commented 8 years ago
There's been some discussion about that here:
https://groups.google.com/forum/#!msg/javacv/rrEyfeIycXQ/SwgRr4ZkBQQJ
If you still have problems, please post your question on that mailing list, 
thank you!

And if you manage to make it work, would you be willing to make a contribution? 
It would be a great addition to these samples!
https://github.com/bytedeco/javacv/tree/master/samples 

Thanks!

Original comment by samuel.a...@gmail.com on 5 Oct 2014 at 9:10

GoogleCodeExporter commented 8 years ago
Good post Sir, However, There is a problem with encoding using javacv 3.0 with 
encoder
Uncompilable source code - Erroneous tree type:

Original comment by kenedyal...@gmail.com on 24 Feb 2015 at 7:55