After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 549171 - appsrc for video/audio recorder
appsrc for video/audio recorder
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
0.10.11
Other All
: Normal normal
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-08-24 02:44 UTC by Yan Chang
Modified: 2008-10-04 21:58 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Yan Chang 2008-08-24 02:44:32 UTC
Please describe the problem:
DEAR:
    i create a pipeline for video and audio record. and video src come from appsrc, auido src come from alsasrc . such as :
   
   appsrc name=v_src ! ... ! ffenc_h263 name=v_enc alsasrc name=a_src ! ... ! amrnbenc name=a_enc ffmux_3gp name=muxer v_enc. ! muxer. a_enc. ! muxer. muxer. ! filesink name=f_sink.

   after i run the pipeline. i couldn't get data form alsasrc, until i use gst_app_src_end_of_stream () end of appsrc. and i found when appsrc is running
alsasrc is wait at gst_pad_push(). if i use videotestsrc instead appsrc it work good , and i can get a good 3gp file.

  i don't konw wether that's a bug in appsrc or alsasrc . or something i wrong in use.

   my gst-plugins-bad version is gst-plugins-bad-0.10.6 , i don't know, if i could importe it if i use gst-plugins-bad-0.10.8. 

thanks


 

Steps to reproduce:
1. 
2. 
3. 


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Wim Taymans 2008-08-25 09:52:21 UTC
It sounds like you do something wrong. The things you describe are perfectly normal when you don't push enough data fast enough in appsrc.

What are pushing in appsrc? Where does the data come from? Your example would suggest it's a live source but you don't have appsrc configured as a live source? Is the data you push timestamped? 

It's also likely that you want to configure caps on the appsrc...
Comment 2 Yan Chang 2008-08-26 01:39:31 UTC
           Thanks for your attention.

         I had user such codes set appsrc caps.

         GstCaps *caps = gst_caps_from_string("video/x-raw-rgb, width=(int)176, height=(int)144, framerate=(fraction)25/2, bpp=(int)16, depth=(int)16, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, endianness=(int)1234");
     gst_app_src_set_caps(GST_APP_SRC(v_src), caps);

   And after run the pipe , I write video/x-raw-rgb data in another thread which create by g_thread_create. The thread will push data to appsrc .

do
{
    .....
    buf = gst_app_buffer_new(tmpbuf, size, gst_app_buf_free, tmpbuf);
    gst_app_src_push_buffer(GST_APP_SRC (v_src), buf);
    ....
}while(1)

 And the pipeline could work good if I only codec video info. 
 
timestamp, I don't konw how to deal it now.  May be question is here, I will study it with fast,   But can you tell me more about it?

                                                                                                                    thank you very much!
Comment 3 Wim Taymans 2008-08-28 15:47:23 UTC
can you check the return value of gst_app_src_push_buffer() ?
Comment 4 Yan Chang 2008-09-09 13:28:31 UTC
thanks you result.

There days I try to find out , where is worg, but i am failed. 

But I see gst_app_src_push_buffer result are GST_FLOW_OK. Please such pipeline , it stilln't work good.

static gboolean write_frame(GstElement* appsrc)
{
    GstBuffer *buf;
    GstFlowReturn ret;
    char tmpbuf[176*144*2] = {0};
    buf = gst_app_buffer_new(tmpbuf, 176*144*2, gst_app_buf_free, tmpbuf);
    if( (ret = gst_app_src_push_buffer(GST_APP_SRC (appsrc), buf) )!= GST_FLOW_OK)
    {
        printf("gst_buf push data error value is %d  \n", ret);
    }
    else
    {
        printf("gst buf pust data ok\n");
    }
    return TRUE;
}
static gpointer camera_capture_thread(gpointer data)
{
    do
    {
        if(g_quit)
        {
            break;
        }
        write_frame(data);
        usleep(200000);
    }while(1);

    g_thread_exit(NULL);
}

int main(int argc, char** argv)
{
    GMainLoop *mainloop;
    GstElement* pipeline;

    g_type_init();
    g_thread_init(NULL);
    gst_init(&argc, &argv);

   pipeline = gst_parse_launch("appsrc name=v_src ! ffmpegcolorspace ! ffenc_h263 name=v_enc ! ffmux_3gp name=mux location=test.3gp alsasrc name=a_src !  audio/x-raw-int,channels=1,rate=8000 ! audioresample ! amrnbenc name=a_enc  a_enc. ! mux. mux. ! filesink location=test.3gp", NULL);

    GstElement* v_src = gst_bin_get_by_name(GST_BIN(pipeline), "v_src");
    GstElement* a_src = gst_bin_get_by_name(GST_BIN(pipeline), "a_src");
    GstCaps* caps = gst_caps_from_string("video/x-raw-rgb, width=(int)176, height=(int)144, framerate=  (fraction)25/2, bpp=(int)16, depth=(int)16, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31,endianness=(int)1234");

    gst_app_src_set_caps(GST_APP_SRC(v_src), caps);
    if(gst_element_set_state (pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
    {
    }

    GThread* capture_thread = g_thread_create(camera_capture_thread, v_src, TRUE, NULL);

    sleep(10);
    g_quit = 1;

  if(gst_element_set_state (GST_ELEMENT(a_src), GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE)
    {
    }
    gst_app_src_end_of_stream(GST_APP_SRC(v_src));
    if(gst_element_set_state (GST_ELEMENT(v_src), GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE)
    {

    }

    if(gst_element_set_state (GST_ELEMENT(pipeline), GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE)
    {

    }

    gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);

}


I run this programe , I found I only get audio data, at sleep time.   and i could get appsrc data untill gst_element_set_state (GST_ELEMENT(a_src), GST_STATE_NULL) 
is do.

THANK YOU VERY MUCH. 
Comment 5 Yan Chang 2008-09-10 10:50:10 UTC
I found if i make appsrc with attribute "do-timestamp=true format=3" It works good.