问题
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.
回答1:
This pipeline captures video from webcam, encodes it in h264 and finally uses flv container to store it at any specified location.
gst-launch-1.0 v4l2src ! videoconvert ! x264enc ! flvmux ! filesink location=xyz.flv
Hope this helps
回答2:
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
回答3:
This directly captures the video from webcam and writes as an avi file which will be played-back by VLC player.
gst-launch v4l2src ! ffmpegcolorspace ! jpegenc ! avimux ! filesink location=output.avi
Hope this help!
来源:https://stackoverflow.com/questions/21152303/how-to-use-gstreamer-to-save-webcam-video-to-file