2 years ago
#64036
TheLazy
Save Video file based on user-input using gstreamer pipeline
I am working on Gstreamer Project, In which I have to record video dynamically based on inputs received over UDP. The video from camera is streamed over udp to streaming device and based on the user input, need to start/stop recording.
After exploring thoroughly over internet, I came across this link, which covers pretty much what I need. Start/Stop Recording dynamically is achieved by hitting (ctrl+c) buttons.
I tried to modify the function to read the data from a json file where the input recieved over udp is written. This modification does not work as the function is not being called anywhere in the pipeline.
I also bumped into this link where changing a filter dynamically is shown. After going through the code, i understood that g_signal_connect()
function can be used to connect my user-defined function to the pipeline. And, I wrote the below snippet and called it using g_signal_connect()
.
static void
pad_added_cb (GstElement * element, GstPad * pad, gpointer user_data)
{
printf("PADD ADDED CAALEED !! \n");
/* JSON VARIABLES */
root = json_object_from_file("configfile.json");
recording = json_object_object_get(root,"Recording");
/* JSON VARIABLE END */
// OFF = 0 &&& ON == 1
if(json_object_get_int(recording) == 0)
{
stopRecording();
}
else if(json_object_get_int(recording) == 1)
{
startRecording();
}
}
and callback added in this way.
g_signal_connect (tee, "pad-added", G_CALLBACK (pad_added_cb), NULL);
However, this throws errors as shown below.
GLib-GObject-WARNING **: 07:27:57.651: invalid (NULL) pointer instance
GLib-GObject-CRITICAL **: 07:27:57.652: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
I have tried everything I could to rectify and make it work but have failed.
Can someone please suggest me the approach I've taken is correct/wrong. Also, if someone could help me in understanding, how i can call a userdefined function along with gstreamer-pipeline which can run iteratively to check some conditions and make certain elements work accordingly. Any suggestion on doing the task other way is also appreciable.
video-capture
tee
gstreamer-1.0
0 Answers
Your Answer