appsrc link to nvvidconv error with reason not-negotiated(-4)

Hi ,
I have test my appsink / appsrc demo .
My appsrc work correctly with following code

appsrc caps=video/x-raw,format=RGBA,width=1920,height=1080 block=true name=appsrc ! videoconvert ! nvoverlaysink

But because of videoconvert it is too slow .
So I want to use nvvidconv instead .with folowing code

appsrc caps=video/x-raw,format=RGBA,width=1920,height=1080 block=true name=appsrc ! video/x-raw,format=RGBA,width=1920,height=1080 ! nvvidconv ! video/x-raw,format=RGBA,width=1920,height=1080! nvoverlaysink

Any return me error

Error received from element appsrc:Internal data flow error .
Streaming task paused ,reason not-negotiated(-4)

My question is what is the different between videoconvet and nvvidconv .

Hi ChrisRiz,

appsrc caps=video/x-raw,format=RGBA,width=1920,height=1080 block=true name=appsrc ! video/x-raw,format=RGBA,width=1920,height=1080 ! nvvidconv ! <b>video/x-raw(memory:NVMM)</b>,format=RGBA,width=1920,height=1080! nvoverlaysink

The output of nvvidconv should be video/x-raw(memory:NVMM)

For more examples, please refer to https://developer.nvidia.com/embedded/dlc/l4t-accelerated-gstreamer-guide-28-2-ga

Hi DaneLLL,
I try with video/x-raw(memory:NVMM) But still error Streaming task paused ,reason not-negotiated(-4)

Hi ChrisRiz,
I don’t see issues with videotestsrc:

$ gst-launch-1.0 videotestsrc ! video/x-raw,format=RGBA,width=1920,height=1080 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=RGBA,width=1920,height=1080' ! nvoverlaysink

Not sure what it does not work for appsrc. Other users may share experience.

Hi , DaneLLL
I am very sure that nvvidconv can not directly connect to appsrc.
And I try videoconvert then it work but with a bit delate .

Below sample works fine. FYR.

$ gst-launch-1.0 videotestsrc num-buffers=1 ! video/x-raw,format=RGBA,width=2048,height=1080 ! filesink location=a.yuv
$ ./test
#include <cstdlib>
#include <gst/gst.h>
#include <gst/gstinfo.h>
#include <gst/app/gstappsrc.h>
#include <glib-unix.h>
#include <dlfcn.h>

#include <cstring>
#include <iostream>
#include <sstream>
#include <thread>

using namespace std;

#define USE(x) ((void)(x))

static GstPipeline *gst_pipeline = nullptr;
static string launch_string;
static GstElement *appsrc_;

GstClockTime timestamp = 0;
static int w = 2048;
static int h = 1080;
static void *ptr = nullptr;

static gboolean feed_function(gpointer user_data) {
    GstBuffer *buffer;
    guint size;
    GstFlowReturn ret;
    GstMapInfo map = {0};

    size = (w*h*4);
    buffer = gst_buffer_new_allocate (NULL, size, NULL);
    buffer->pts = timestamp;

    gst_buffer_map (buffer, &map, GST_MAP_WRITE);
    memcpy(map.data, ptr , size);
    gst_buffer_unmap(buffer, &map);

    g_signal_emit_by_name (appsrc_, "push-buffer", buffer, &ret);
    gst_buffer_unref(buffer);

    timestamp += 33333;
    return G_SOURCE_CONTINUE;
}

int main(int argc, char** argv) {
    USE(argc);
    USE(argv);

    gst_init (&argc, &argv);

    GMainLoop *main_loop;
    main_loop = g_main_loop_new (NULL, FALSE);
    ostringstream launch_stream;

    launch_stream
    << "appsrc name=mysource ! "
    << "video/x-raw,width="<< w <<",height="<< h <<",framerate=30/1,format=RGBA ! "
    << "nvvidconv ! video/x-raw(memory:NVMM),format=RGBA ! "
    << "nvoverlaysink ";

    launch_string = launch_stream.str();

    g_print("Using launch string: %s\n", launch_string.c_str());

    GError *error = nullptr;
    gst_pipeline  = (GstPipeline*) gst_parse_launch(launch_string.c_str(), &error);

    if (gst_pipeline == nullptr) {
        g_print( "Failed to parse launch: %s\n", error->message);
        return -1;
    }
    if(error) g_error_free(error);

    appsrc_ = gst_bin_get_by_name(GST_BIN(gst_pipeline), "mysource");
    gst_app_src_set_stream_type(GST_APP_SRC(appsrc_), GST_APP_STREAM_TYPE_STREAM);

    guint size;
    size = (w*h*4);
    FILE *fp = fopen ("/home/nvidia/a.yuv", "rb");
    ptr = malloc(size);
    fread(ptr, size, 1, fp);
    fclose(fp);

    gst_element_set_state((GstElement*)gst_pipeline, GST_STATE_PLAYING); 

    for (int i=0; i<150; i++) {
        feed_function(nullptr);
        usleep(33333);
    }

    gst_element_set_state((GstElement*)gst_pipeline, GST_STATE_NULL);
    gst_object_unref(GST_OBJECT(gst_pipeline));
    g_main_loop_unref(main_loop);

    free(ptr);
    g_print("going to exit \n");
    return 0;
}

A relative post https://devtalk.nvidia.com/default/topic/1026106/jetson-tx1/usage-of-nvbuffer-apis/post/5219225/#5219225

a.cpp (2.44 KB)

somebody who use this code ,should be careful about the file name of 81 lines,use your file name replace “/home/nvidia/a.yuv”

compile:
g++ -Wall -std=c++11 test.cpp -o test $(pkg-config --cflags --libs gstreamer-app-1.0) -ldl