I've been learning GStreamer to manage and forward streams from one RTMP server to another. I've hit a roadblock when trying to replicate the tutorial found here, albeit without the data buffer. Whenever I run the program, it stops when I set the rtmpsink
URL. It doesn't throw an error on that line or report that the pipeline couldn't start to ret
, it just stops. The first part of the code is below
GstElement* pipeline = nullptr;
GstBus* bus = nullptr;
GstMessage* msg = nullptr;
GstStateChangeReturn ret;
gboolean terminate = FALSE;
GstElement* source, *sink, *mux;
gst_init(&arg, &argv);
// Create Elements
source = gst_element_factory_make("rtmpsrc","source");
sink = gst_element_factory_make("rtmpsink","sink");
mux = gst_element_factory_make("flvmux", "mux");
pipeline = gst_pipeline_new("test-pipeline");
// add items to bin and
gst_bin_add_many(GST_BIN(pipeline), source, mux, sink, NULL);
if (!gst_element_link_many(source, mux, sink, NULL)) {
g_printerr("oh no");
gst_object_unref(pipeline);
return -1;
}
g_object_set(source, "location", "rtmp://localhost/live/Stream-A");
// Here is where the code stops
g_object_set(sink, "location", "rtmp://localhost/live/Stream-B");
ret = gst_element_set_state(pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr("Unable to set the pipeline to the playing state.\n");
gst_object_unref(pipeline);
return -1;
}
I've looked for other questions about rtmpsink
, most of the answers said to use flvmux
to format the audio and video properly.
Is there something I'm missing in the set
call? Should I use a different sink?
Update 1 After a bit more digging, I've realized that I was debugging the wrong way. After using VS correctly, I ran into the following error:
Exception thrown at 0x00007FF9FC2B1C3C (vcruntime140.dll)
in gstream_switch.exe: 0xC0000005: Access violation reading location
0x0000000000000000
So it looks like this is just a case of referencing unallocated memory. I haven't found the answer, so I'm not marking this answered yet. Looking at other posts, my guess is that maybe I'm not using debugging libraries/variables, but I don't know.
g_object_set()
needs to end with a NULL
parameter to indicate an end as you can set multiple parameters with one call.
Try:
g_object_set(source, "location", "rtmp://localhost/live/Stream-A", NULL);
g_object_set(sink, "location", "rtmp://localhost/live/Stream-B", NULL);
User contributions licensed under CC BY-SA 3.0