Pipeline works in terminal, but not in C

I’m trying to stream a video and save it to disk with splitmuxsink. I’ve managed to get the pipeline to work as a terminal command, but I’m getting a couple of errors with the C code. The terminal pipeline that works is:

gst-launch-1.0 videotestsrc ! video/x-raw,width=320,height=240 ! videoconvert ! tee name=t  t. ! queue ! nvoverlaysink  t. ! queue ! timeoverlay ! omxh264enc ! h264parse ! splitmuxsink max-files=3 max-size-time=3000000000 location=video%02d.mp4

The errors that the C code is giving are:

DEBUG  e[00m e[00;01;36m  GST_PLUGIN_LOADING  gstplugin.c:1549:gst_plugin_ext_dep_scan_dir_and_match_names:<plugin134>e[00m g_dir_open(/dev/v4l2) failed: Error opening directory '/dev/v4l2': No such file or directory

and

WARN  e[00m e[00m  omx gstomx.c:2826:plugin_init:e[00m Failed to load configuration file: Valid key file could not be found in search dirs (searched in: /home/nvidia/.config:/etc/xdg as per GST_OMX_CONFIG_DIR environment variable, the xdg user config directory (or XDG_CONFIG_HOME) and the system config directory (or XDG_CONFIG_DIRS)

The full C code and log output (debug level 5) can be found here: https://github.com/AtomicJosh/random_projects

Any ideas on what’s wrong with the C code? I’ve tried googling those errors and haven’t found anything definitive.

It seems the gst-launch command is using videotetsrc as source, while your C code is trying to use v4l2 as source.
I’d suggest to use first v4l2src plugin with gst-launch in order to check the right config (also not sure ‘/dev/v4l2’ is a good path, you may just try /dev/videoX where X is your source camera index).

That would make logical sense, but the code is using videotestsrc as well. Just as a dummy check, I did a text search in the code for “v4l2” with no matches. I don’t know where the “/dev/v4l2” is coming from in the debug file.

Also, in case you’re wondering, v4l-utils is installed.

Not sure I can help, but what is your camera ? Is it a USB cam ? What is the /dev/videoX shown by its driver ?
What gives ?

v4l2-ctl -d /dev/videoX --list-formats

Ultimately, it will be coming from a USB cam, but it isn’t currently connected (it is a bit of a pain to set up and get going). When it is connected, it is /dev/video1. I can connect it and get the details if you’d like, but shouldn’t it not matter in this case since I’m using the videotestsrc?

I’m sorry I cannot say more if your code is trying to run videotestsrc and it looks for /dev/v4l2.
I may help further when you’ll have a real cam (not sure I’ll be able however…).