On Mac, it was hard to find out how to capture web camera input to me and this is to share what i found in dealing with gstreamer to capture live webcam input on my Macbook running OS X 10.7.5.



To use GStreamer, the necessary package should be installed and the following link shows how to install it.


http://docs.gstreamer.com/display/GstSDK/Installing+on+Mac+OS+X


Before running gst-launch, few more steps are needed because the path containing the gst binaries may not be included in PATH env variable. I recommend that few symbolic links to gst binaries be created in /usr/bin/ path.

For example, at command line, run below command to create those files.


$ sudo ln -s /Library/Frameworks/GStreamer.framework/Versions/Current/bin/gst-launch-0.10 /usr/bin/gst-launch

$ sudo ln -s /Library/Frameworks/GStreamer.framework/Versions/Current/bin/gst-inspect-0.10 /usr/bin/gst-inspect


Now we can test whether gstreamer is working properly.


Example 1: Testing with pre-made video source in gstreamer and displaying it in a window.


$ gst-launch videotestsrc ! osxvideosink


Example 2: Displaying webcam input in a window


$ gst-launch autovideosrc ! osxvideosink



Example 3: Grabbing one frame from webcam and saving it as jpeg


$ gst-launch -v -e autovideosrc num-buffers=1 ! jpegenc ! filesink location=capture1.jpeg


So far, all examples above are shown as command line use case.

Before completing this post, here come a sample c source code with cmake script which will ease developing user application for one's own use. The source file is taken from gstreamer tutorial page at http://docs.gstreamer.com/pages/viewpage.action?pageId=327735 so if details about it is required, then you can check it also in the link.


This project source was tested with my macbook.



gst-example-prj.tar.7z


 

Posted by kevino
,