This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Gstreamer broken frame

Hi.

I try to encode video using gstreamer. I can successfully encode test video by using the following pipeline:

gst-launch -v videotestsrc ! 'video/x-raw-yuv, width=1024 , height=768, format=(fourcc)NV12, framerate=30/1' ! omx_h264enc ! 'video/x-h264' ! avimux !  gstperf ! filesink location=colorbar.264 sync=false

But what i need is to manage encoding from a program and to encode frames from RAM. So i wrote such a program. Unfortunately when i play an output file, i see that some frames are broken, although i use a static frame as a source (it is just for testing).

Here are good and bad frames:

And here is part of my code:

start function()

{

gst_init (&argc, &argv);

loop = g_main_loop_new (NULL, FALSE);

GstElement *pipeline, *appsrc;
    GstCaps *caps;
    pipeline = gst_parse_launch("appsrc name=mysource ! video/x-raw-yuv, width=1024 , height=768, format=(fourcc)NV12, framerate=10/1 ! omx_h264enc bitrate=100000 ! video/x-h264 ! avimux ! gstperf ! filesink location=film.avi sync=false", NULL);

appsrc = gst_bin_get_by_name (GST_BIN(pipeline), "mysource");

caps = gst_caps_new_simple("video/x-raw-yuv",
                                "width", G_TYPE_INT, 1024,
                                "height", G_TYPE_INT, 768,
                                //        "format"=(fourcc){NV12}
                                "framerate", GST_TYPE_FRACTION, 10, 1,
                                "bpp", G_TYPE_INT, 16,
                                "depth", G_TYPE_INT, 16,
                                "endianness", G_TYPE_INT, G_BYTE_ORDER,
                                NULL);
    gst_app_src_set_caps(GST_APP_SRC(appsrc), caps);

    gst_element_set_state(pipeline, GST_STATE_PLAYING);

g_main_loop_run(loop);

}

The following function is called from another thread.

void* pushingLoop(void* ptr)
{
    struct SPusher* pusher = (struct SPusher*)ptr;
    int n = 1;
    unsigned char* addr = pusher->fbdev->m_buffer;
    addr += 1024 * 768 * 3;
    fill_color_bar(addr, 1024, 1024, 768, n);
    fill_color_bar(addr + 1024 * 768 * 2, 1024, 1024, 768, n);
    usleep(1000 * 150);
    while(1)
    {
        /* create the buffer */
        GstBuffer *buffer = gst_buffer_new();
        if(n)
            GST_BUFFER_DATA (buffer) = addr;
        else
            GST_BUFFER_DATA (buffer) = addr + 1024 * 768 * 2;
        GST_BUFFER_SIZE (buffer) = 1024 * 768 * 2;
        /* push the buffer to pipeline via appsrc */
        GstFlowReturn gstFlowReturn = gst_app_src_push_buffer(GST_APP_SRC(pusher->appsrc), buffer);
        if (gstFlowReturn != GST_FLOW_OK)
        {
            /* some error, stop sending data */
            GST_DEBUG ("some error");
        }
        usleep(1000 * 200);

//        fill_color_bar(addr, 1024, 1024, 768, n);
//        n = n ? 0 : 1;
    }

    return NULL;
}

I use dm8148, ti-ezsdk_dm814x-evm_5_04_00_11.

Best regards,

Alexander Vasiljev.