Search code examples
copencvgstreameravix264

How to use gstreamer to save webcam video to file?


I've been trying to get emgu to save same webcam video to file

The problem is opencv only ssupports avi, and avi does not seem to suit a format like X264 very well.

Could I use Gstreamer to do this for me in C?

It would be good if I could choose the file format and container type too. It would be good if I could use a format like schrodinger dirac.

I'm new to GStreamer so I'm not quite sure if I'm on the right track here.

EDIT

I've managed to capture the webcam video using

gst-launch-0.10 ksvideosrc ! autovideosink

Now how to transcode this to a format like H264 or dirac ...?

EDIT

gst-launch-0.10 ksvideosrc num-buffers=10 ! decodebin2 ! ffmpegcolorspace ! x264enc ! matroskamux ! filesink location=video.mkv

This seems to create a file, but VLC player can't read it.


Solution

  • This

    gst-launch-0.10

    ksvideosrc !  
    decodebin2 !      
    ffmpegcolorspace !
    schronc ! 
    matroskamux ! 
    filesink location=gopro2.mkv
    

    Seems to handle dirac encoding

    And this

    gst-launch-0.10 ksvideosrc num-buffers=500 ! decodebin2 ! ffmpegcolorspace ! x264enc ! mp4mux ! filesink location=gopro2.mp4

    Handles x264