gst_element_factory_make("nvcamerasrc", NULL) returns NULL while a command line pipeline works well


The following command runs successfully:

gst-launch-1.0 nvcamerasrc ! ‘video/x-raw(memory:NVMM),width=1280, height=720, framerate=30/1’ ! omxh265enc ! filesink location=test.mkv

gst-inspect-1.0 nvcamerasrc
also works well.

But when try to run the code:
gst_element_factory_make(“nvcamerasrc”, NULL)
it gets NULL

I guess it happens because of environment as my code runs within AWS kinesis SDK framework which probably sets specific environment.
Could you suggest where to dig?
Thank you!

If you check at gstreamer doc for this function, you’ll see that the second argument is a string with plugin name. Try to provide one with something like:

gst_element_factory_make("nvcamerasrc", "source")

Furthermore your pipeline above saves raw H265 stream, not a mkv. You may use plugin matroskamux for using such container:

gst-launch-1.0 -e nvcamerasrc ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=30/1' ! omxh265enc ! h265parse ! matroskamux! filesink location=test.mkv

I tried it too with the same result.
BTW the second parameter can be NULL to allow the pipeline to assign a unique name.

The command is used only to check if nvcamerasrc works. It writes a file which is enough for now.
So, the reason of the problem is in something else. Probably in environment variables.
Thank you.

You may check with ldd which libs are found four your app in your environment and see if it is as expected.

Have you built your app in debug mode and run it from gdb in order to see where it faults ?

ldd gives: not a dynamic executable, that’s all

My test app has just this:

#include <gst/gst.h>

int main (gint argc, gchar * argv[])
	GstElement *source;
	gst_init (&argc, &argv);
	source = gst_element_factory_make ("nvcamerasrc", NULL);
  if (!source) {
    g_print ("'nvcamerasrc' gstreamer plugin missing\n");
    return 1;
  return 0;

It works for “v4l2src” but not for “nvcamerasrc”.
At the same time
gst-launch-1.0 nvcamerasrc <…>

I ran
sha1sum -c /etc/nv_tegra_release
and get
/usr/lib/aarch64-linux-gnu/tegra/ OK

Do you have an idea why gst-launch-1.0 can see nvcamerasrc but the app can not?

How did you build your app ?
I cannot check now on TX2, but on a TK1 I just compiled your code with:

gcc -o test_gst test_gst.cpp `pkg-config --cflags --libs gstreamer-1.0`

ldd ./test_gst => /usr/lib/arm-linux-gnueabihf/ (0xb6e55000) => /lib/arm-linux-gnueabihf/ (0xb6d8d000) => /lib/arm-linux-gnueabihf/ (0xb6d6c000) => /lib/arm-linux-gnueabihf/ (0xb6d51000) => /lib/arm-linux-gnueabihf/ (0xb6c69000) => /usr/lib/arm-linux-gnueabihf/ (0xb6c2b000) => /usr/lib/arm-linux-gnueabihf/ (0xb6c20000) => /lib/arm-linux-gnueabihf/ (0xb6bb4000) => /lib/arm-linux-gnueabihf/ (0xb6ba9000)
	/lib/ (0xb6f2e000) => /lib/arm-linux-gnueabihf/ (0xb6b71000) => /usr/lib/arm-linux-gnueabihf/ (0xb6b62000)

Execution on TK1 shows no error nor message.

[EDIT: confirmed on my TX2.

ldd ./test_gst =>  (0x0000007faf124000) => /usr/lib/aarch64-linux-gnu/ (0x0000007faefd8000) => /lib/aarch64-linux-gnu/ (0x0000007faeed1000) => /lib/aarch64-linux-gnu/ (0x0000007faeea5000) => /lib/aarch64-linux-gnu/ (0x0000007faed5d000) => /usr/lib/aarch64-linux-gnu/ (0x0000007faed01000) => /usr/lib/aarch64-linux-gnu/ (0x0000007faeced000) => /lib/aarch64-linux-gnu/ (0x0000007faec3f000) => /lib/aarch64-linux-gnu/ (0x0000007faec2c000)
	/lib/ (0x000000557197f000) => /lib/aarch64-linux-gnu/ (0x0000007faebbb000) => /usr/lib/aarch64-linux-gnu/ (0x0000007faeba2000)

Now, when I used your command:
gcc -o test_gst test_gst.cpp pkg-config --cflags --libs gstreamer-1.0

I could get a proper ldd output. Before I used makefile supplied by Kinesis SDK.

About the issue itself: the reason was that Kinesis SDK ( has its own supply of gstreamer including plugins and overwrites the lib path so that an app cannot get /usr/lib/aarch64-linux-gnu/tegra/ to find nvcamerasrc.
It is resolved by:

export GST_PLUGIN_PATH=/usr/lib/aarch64-linux-gnu/tegra/:/usr/lib/aarch64-linux-gnu/gstreamer-1.0

More info is here:

Thank you!