since 0061 all the video in linux is managed using gstreamer, the file that does both the videograbbing and videoplayer is ofGstUtils. although right now is only working in linux, it should work in windows and mac and probably in the iphone just by compiling gstreamer and it’s dependencies.
this is an example of what can be done with it + an addon for recording to video files or streaming through the network.
ofxGstVideoRecorder is an addon that allows to record part of an OF app, the desktop, or any ofBaseImage/ofBaseVideo and save it to a file with different codecs or stream it through the network using udp or tcp. you can even stream it to vlc and use it as an http stream server.
in ofGstUtils there’s a method setPipeline that allows to set a custom gstreamer pipeline. in ofGstExamples there’re some examples of what can be done:
- receive streams from another OF app using tcp or udp
- receive the content of the desktop in an OF app (only linux)
- reading axis cameras jpeg streams
some of this examples need a slight mod to setPipeline in ofGstUtils (wil be in 0062 : )
bool ofGstUtils::setPipeline(string pipeline, int bpp, bool isStream, int w, int h){
this->bpp = bpp;
bHavePixelsChanged = false;
bIsStream = isStream;
gstData.loop = g_main_loop_new (NULL, FALSE);
if(w!=-1 && h!=-1){
width=w;
height=h;
}
string caps;
if(bpp==1)
caps="video/x-raw-gray, depth=8, bpp=8";
else if(bpp==3)
caps="video/x-raw-rgb, depth=24, bpp=24";
else if(bpp==4)
caps="video/x-raw-rgb, depth=32, bpp=32";
gchar* pipeline_string =
g_strdup((pipeline + " ! appsink name=sink caps=\"" + caps + "\"").c_str()); // caps=video/x-raw-rgb
GError * error = NULL;
gstPipeline = gst_parse_launch (pipeline_string, &error);
ofLog(OF_LOG_NOTICE, "gstreamer pipeline: %s", pipeline_string);
if(error!=NULL){
ofLog(OF_LOG_ERROR,"couldnt create pipeline: " + string(error->message));
return false;
}
gstSink = gst_bin_get_by_name(GST_BIN(gstPipeline),"sink");
gst_base_sink_set_sync(GST_BASE_SINK(gstSink), true);
return startPipeline();
}