Segmentation Fault
Ian Davidson
id012c3076 at blueyonder.co.uk
Wed Dec 2 05:15:22 PST 2015
I want to 'read in' a video file, re-code it and write out a new file.
I notice that playbin has video-sink and audio-sink properties which
apparently allow the video and audio to be sent to other than the
default locations - so I attempted something like shown below.
It did not work as I wanted - but instead reported a Segmentation
Fault. My guess is that I have done something wrong trying to set the
video-sink property on playbin (and then also the audio-sink property).
Below, I have listed the heart of my program and then the tail of the
output from GST_DEBUG=4.
I would appreciate any insight as to where I've gone wrong - or a better
way to achieve my objective!
Ian
loop = g_main_loop_new (NULL, FALSE);
/* Create gstreamer elements */
pipeline = gst_pipeline_new ("av-recorder");
playbin = gst_element_factory_make ("playbin",
"playbin-element");
queue1a = gst_element_factory_make ("queue", "queue1a");
vidrate = gst_element_factory_make ("videorate", "vidrate");
vidscale = gst_element_factory_make ("videoscale", "vidscale");
vcapsfilter = gst_element_factory_make ("capsfilter", "vid-caps");
queue1 = gst_element_factory_make ("queue", "queue1");
vidconvert = gst_element_factory_make ("videoconvert","vidconvert");
videnc = gst_element_factory_make ("x264enc", "videnc");
acapsfilter = gst_element_factory_make ("capsfilter", "audio-caps");
queue2 = gst_element_factory_make ("queue", "queue2");
audrate = gst_element_factory_make ("audiorate", "audrate");
queue3 = gst_element_factory_make ("queue", "queue3");
lameenc = gst_element_factory_make ("lamemp3enc", "lameenc");
mux = gst_element_factory_make ("mp4mux", "mp4-mux");
sink = gst_element_factory_make ("filesink", "file-output");
queue4 = gst_element_factory_make ("queue", "queue4");
if (!pipeline || !playbin || !vidrate || !vcapsfilter || !queue1 ||
!videnc || !acapsfilter || !queue2 || !audrate || !queue3 || !lameenc ||
!mux || !sink) {
g_printerr ("One element could not be created. Exiting.\n");
return;
}
/* Set up the pipeline */
g_object_set (G_OBJECT (playbin), "uri",
"file:///home/ian/superRecord/MOV05E.Mpg", NULL);
g_object_set (G_OBJECT (sink), "location",
"/home/ian/superRecord/testVid.Mp4", NULL);
g_object_set (G_OBJECT (videnc), "tune", 0x0004, NULL); /*zerolatency*/
g_printerr ("Properties set.\n");
/* set the video capabilities on the vidcaps element */
/* SET THE VIDEO CAPS */
caps =
gst_caps_from_string("video/x-raw,format=(string)I420,width=720,height=576,framerate=(fraction)25/1");
g_object_set (G_OBJECT (vcapsfilter), "caps", caps, NULL);
gst_caps_unref (caps);
/* set the audio capabilities on the audiocaps element */
caps = gst_caps_from_string("audio/x-raw,rate=44100,channels=1");
g_object_set (G_OBJECT (acapsfilter), "caps", caps, NULL);
gst_caps_unref (caps);
/* add a message handler */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* add all elements into the pipeline */
gst_bin_add_many (GST_BIN (pipeline),
playbin, queue1a, vidrate, vidscale, vcapsfilter, queue1,
vidconvert, videnc,
queue4, acapsfilter, queue2, audrate, queue3, lameenc,
mux, sink, NULL);
/* link the elements together */
if (!gst_element_link_many (queue1a, vidrate, vidscale,
vcapsfilter, queue1, videnc, mux, NULL)) {
g_printerr ("Failed to link queue1a, vidrate, vidscale,
vcapsfilter, queue1, videnc, mux. Exiting.\n");
return;
}
if (!gst_element_link_many (queue4, acapsfilter, queue2, audrate,
queue3, lameenc, mux, NULL)) {
g_printerr ("Failed to link queue4, acapsfilter, queue2, audrate,
queue3, lameenc, mux. Exiting.\n");
return;
}
g_print ("Most Links Linked!\n");
if (!gst_element_link_many (mux, sink, NULL)) {
g_printerr ("Failed to link mux to sink. Exiting.\n");
return;
}
g_print ("All Links Linked!\n");
g_print ("Link Video-Sink of playbin\n");
g_object_set (G_OBJECT (playbin), "video-sink", "queue1a", NULL);
g_print ("Link Audio-Sink of playbin\n");
g_object_set (G_OBJECT (playbin), "audio-sink", "queue4", NULL);
/* Set the pipeline to "playing" state*/
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Iterate */
g_main_loop_run (loop);
Most Links Linked!
0:00:02.273452582 1690 0x9368bc0 INFO GST_ELEMENT_PADS
gstutils.c:1543:gst_element_link_pads_full: trying to link element
mp4-mux:(any) to element file-output:(any)
0:00:02.273503575 1690 0x9368bc0 INFO GST_PADS
gstutils.c:936:gst_pad_check_link: trying to link mp4-mux:src and
file-output:sink
0:00:02.273581778 1690 0x9368bc0 INFO GST_PADS
gstutils.c:1443:prepare_link_maybe_ghosting: mp4-mux and file-output in
same bin, no need for ghost pads
0:00:02.273625793 1690 0x9368bc0 INFO GST_PADS
gstpad.c:2120:gst_pad_link_prepare: trying to link mp4-mux:src and
file-output:sink
0:00:02.273674557 1690 0x9368bc0 INFO GST_PADS
gstpad.c:2322:gst_pad_link_full: linked mp4-mux:src and
file-output:sink, successful
0:00:02.273708267 1690 0x9368bc0 INFO GST_EVENT
gstevent.c:1313:gst_event_new_reconfigure: creating reconfigure event
0:00:02.273737465 1690 0x9368bc0 INFO GST_EVENT
gstpad.c:5083:gst_pad_send_event_unchecked:<mp4-mux:src> Received event
on flushing pad. Discarding
All Links Linked!
Link Video-Sink of playbin
Segmentation fault
More information about the gstreamer-devel
mailing list