Appsink is only apparently processing 25% of data

Tim Müller tim at centricular.com
Tue Oct 25 19:49:14 UTC 2016


On Tue, 2016-10-25 at 12:24 -0700, Michael Rappaport wrote:

Hi Michael,

> I have a pipeline that is taking in an RTP MPEG-2 TS, and doing a few
> things:
> 1) Playing back video and audio
> 2) Using *filesink* to save the file to disk
> 3) Using *appsink* to save samples to disk when they are received.
> 
> Basically, the program is creating two files, one by stdio, and one
> by the filesink. Because I am using a tee, I would expect the appsink
> file and the filesink file to be exactly the same. However, the
> appsink file is not nearly as big as the filesink file. I've been
> struggling with this one for quite some time, and any assistance
> would be greatly appreciated.
> 
> Here is my code:
>  (snip)
> 
> 	sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
> 	//retreive buffer data
> 	GstMapInfo map;
> 	gst_buffer_map(gst_sample_get_buffer(sample), &map,
> GST_MAP_READ);
> 	//printe buffer data
> 	fprintf(myfile, "%s", map.data);

This printf doesn't look right. The buffer is binary data, it's
basically a bunch of bytes. It might contain bytes that are 0.
printf("%s") will print the data until a 0 byte is encountered. In that
case it will write less data than there is in the buffer. If the buffer
does not contain a 0 byte it may read beyond the allocated memory and
write garbage into the file or even crash.

Try something like:

  fwrite(map.data, map.size, 1, myfile);

(Return value should be 1 on success).

Cheers
 -Tim

-- 
Tim Müller, Centricular Ltd - http://www.centricular.com


More information about the gstreamer-devel mailing list