[gst-devel] appsrc to filesink

Andres Colubri andres.colubri at gmail.com
Tue Feb 3 18:02:33 CET 2009


I've been trying a few more things. Basically what I do is first set the 
pipeline to playing, then push the buffers through appsrc, and finally I 
run the main application loop:

int
main (int argc, char *argv[])
{
...
gst_element_set_state (data->sink, GST_STATE_PLAYING);

for (i = 0; i < 30; i++) inject_new_buffer_into_pipeline(data);
gst_app_src_end_of_stream (GST_APP_SRC (testsource));

gst_element_set_state (data->sink, GST_STATE_PLAYING);

g_main_loop_run (data->loop);
...
}

I'm assuming that by running the main loop, the buffers in the appsrc 
queue would go through the rest of the pipeline and will be finally 
encoded and written to disk. Is this correct?

The inject_new_buffer_into_pipeline() function just pushes the buffers:

inject_new_buffer_into_pipeline (ProgramData * data)
{
  guint size;
  gpointer raw_buffer;
  GstBuffer *app_buffer;
  GstElement *source;

  size = 80 * 60 * 4; // 80x60 pixels, 32 bpp.
  g_print ("Pushing a buffer of size %d\n", size);
 
  // Allocating the memory for the buffer.
  raw_buffer = g_malloc0 (size);
 
  app_buffer = gst_app_buffer_new (raw_buffer, size, g_free, raw_buffer);

  /* newer basesrc will set caps for use automatically but it does not 
really
   * hurt to set it on the buffer again */
  gst_buffer_set_caps (app_buffer, gst_caps_from_string (video_caps));

  /* get source an push new buffer */
  source = gst_bin_get_by_name (GST_BIN (data->sink), "testsource");
  gst_app_src_push_buffer (GST_APP_SRC (source), app_buffer);
}

I'm not setting any duration or timestamp for the pushed buffers, so 
this could be a problem as well?

Anyways, the program runs and doesn't give any error, even though the 
resulting avi file is invalid. The complete code of the example is attached.

> Many thanks for the comments. I corrected both caps (the one used for 
> ffmpegcolorspace and the one in appsrc). This is how they look like now:
>
> video/x-raw-yuv,format=(fourcc)I420,width=80,height=60 (for 
> ffmpegcolorspace)
> video/x-raw-rgb,width=80,height=60,bpp=32,endianness=4321,depth=24,red_mask=65280,green_mask=16711680,blue_mask=-16777216,framerate=30/1 
> (for appsrc)
>
> I also set the is-live property of appsrc to true.
>
> The program runs ok and gives no error. However, the resulting avi 
> file is completely empty (0 bytes). I also tried ffmpegcolorspace 
> without caps, and appsrc without is-live=true, but the same result.
>
> Do you suggest any other change/test in the code to try to locate 
> where the problem is?
>
> I attached the latest version of the example, just in case anyone 
> wants to take a look.
>
> Again, thanks a lot.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: appsrc_filesink.c
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20090203/0ddef715/attachment.asc>


More information about the gstreamer-devel mailing list