Filesink from C code, file always empty

Sebastian Dröge sebastian at centricular.com
Thu Nov 20 02:30:06 PST 2014


On Do, 2014-11-20 at 10:21 +0000, Paul Barber wrote:
> Paul Barber wrote:
> >>Hi,
> >>I am having trouble writing a C application to put video to screen and to file at the same time. I have a >>command line pipeline that works:
> >>
> >>gst-launch-1.0 videotestsrc num-buffers=100 ! tee name=t ! queue ! videoconvert !
> >>xvimagesink sync=false t. ! queue ! videorate ! video/x-raw,framerate=25/1 !
> >>videoconvert ! avenc_mpeg2video bitrate=3000000 ! avimux !
> >>filesink location=test_file.avi async=0
> >>
> >>but in code this does not work. I always end up with an empty file (0 bytes).
> >>
> >>I have reduce the code down and put it on github:
> >>https://gist.github.com/paulbarber/7d2e43d1e3365b2042aa
> >>
> >>All the action is in play_camera() in play.c.
> >>
> >>I would be really grateful if anyone has any clue as to what is wrong. 
> 
> Sebastian Dröge wrote:
> >Did you check if all the pad linking you do succeeds? Always check the
> >return values.
> >
> >Also did you take a look at the pipeline graph once it's started by
> >using GST_DEBUG_BIN_TO_DOT_FILE() to see if it looks the way you expect
> >it to look?
> >
> >And do you get any errors when you run that pipeline, or did you try
> >looking at the GStreamer debug logs already?
> Thank you for your reply, that was all the help I needed. I had done 2
> of the 3 but had not looked at the graph. This revealed that I was not
> requesting tee pads correctly.
> Should use gst_element_request_pad(), for each tee pad required.
> Not, gst_element_get_request_pad() as this does not create request
> pads.
> Nor, gst_element_get_compatible_pad() as this will only create one
> request pad, then return that same pad on all subsequent calls.

You could also use gst_element_link() as it will automagically request
pads too. But it's indeed better to use gst_element_get_request_pad() as
it makes it more explicit that we're dealing with a request pad here.

-- 
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 949 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20141120/8e428e84/attachment-0001.sig>


More information about the gstreamer-devel mailing list