View on GitHub

raspberry_ninja

Publish or capture VDO.Ninja streams with Python (Raspberry Pi, Linux, Mac, Windows WSL)

A version for the Nvidia Jetson

This is very much like the RPI version, but uses the Nvidia Jetson (Nano/NX/AGX). The Nvidia Jetson tends to have more power and likely will give better results; it is more expensive though. 1080p30 should be quite easy for an Nvidia Jetson to handle, which can’t be said for a Raspberry Pi.

Choose the right script

Most users who download a pre-built Jetson image only need to grab the latest Raspberry Ninja code and dependencies. Use the new lightweight helper:

cd ~/raspberry_ninja/installers/nvidia_jetson
chmod +x quick_update.sh setup_autostart.sh   # first run only
./quick_update.sh

quick_update.sh performs a safe apt refresh, installs the small set of runtime packages the project currently relies on (including the new display tools), and leaves distro packages and JetPack components untouched.

Only run installer.sh if you are building a brand-new image from the stock Nvidia JetPack release or repairing a completely broken system. It performs major cleanups, removes large desktop packages, and attempts a distro upgrade, all of which are unnecessary—and potentially disruptive—on top of the provided pre-built images.

Disable screen blanking

When you run sudo ./setup_autostart.sh it now asks whether to disable the Jetson screen blanking and DPMS timeouts (the default answer is yes). Accepting the prompt installs an X11 config that disables DPMS, enables a small systemd unit to keep the virtual consoles awake, and restarts the active display manager so the change takes effect immediately.

If you previously skipped the prompt, simply rerun setup_autostart.sh and choose the same answers for your service — only the blanking step needs sudo so the rest of the configuration can stay unchanged.

Installing from an official Nvidia Image

While you can probably install Raspberry_ninja onto any Linux flavour, Nvidia’s Jetpack Ubuntu version contains the drivers needed to make use of the hardware encoder. I provide some pre-built images, that are setup with all the depedencies needed to run Raspberry_Ninja, but you can use the official image and DIY also.

See the installer.sh for the most recent installer used by me to make the current distributable image baed on an official Nvidia image. You’ll want to run section at a time, to ensure things run smoothly, restarting or manually editing files as needed.

You are more than likely going to need to make changes to the installer though, as it tries to build the newest version of Gstreamer, and that often implies other script changes are needed.

Takes a few hours at least to normally get everything working when building the files from scratch. Some steps can be skipped to speed things up, like SRT / FFMPEG support, so do what you wish.

Instalilng on Jetson without original Nvidia image?

If you aren’t using the Nvidia Jetson image, or you’ve messed things up, you can download the gst-files provided by Nvidia on that image here, libgstnvidia.zip, as a zip:

Assuming you bypass any related errors in the install script, you’ll need to extract and copy those files to this folder, once the install script finishes: /usr/local/lib/aarch64-linux-gnu/gstreamer-1.0$

You can also try copying those files to the following folder, before running the script, and hope the script detects them correctly without errors: /usr/lib/aarch64-linux-gnu/gstreamer-1.0/

I’ve seen an interesting git repo with details on building a Jetson image yourself here, https://github.com/pythops/jetson-nano-image, although I haven’t tried it yet. You’re on your own if you go this path tho.

Steve provided completed builds

The newest pre-setup images for Jetson devices requires 16-GB uSD card or larger, along with a Jetson running the newest board firmware.

You can use Win32DiskImager (https://sourceforge.net/projects/win32diskimager/) to write this image to a disk. If you need to format your SD card first, you can use the SD Card Formatter (https://www.sdcard.org/downloads/formatter/).

If you have problems with Win32DiskImager, Bletcher might be an option?

Install Steve’s newest Jetson Nano image below; last updated April 21st, 2023.

https://drive.google.com/file/d/1B_ywphXQ49F9we3ytcM-Zn1h7dCYOLBh/view?usp=share_link

The above image was built on a Jetson Nano 2GB developer kit, model A02, with up-to-date firmware. It may work with the Jetson Nano 4GB model also, assuming firmware is up to date.

The username and password to sign in to the image is:

username: ninja
password: vdo

(if the password doesn’t work, try vdo for the username and ninja for the password, instead)

If the Jetson fails to boot after installing it, try an older image, provided below, or considering updating the firmware on your Jetson to something newer. If nothing else works, you can build Raspberry_ninja from scratch using the installer.sh file, located in the nvidia_jetson folder.

If the installation doesn’t auto-expand to fill your uSD card on boot, you can run the following commands to have it use the available disk space:

sudo apt-get install cloud-utils -y
sudo growpart /dev/mmcblk0 1
sudo resize2fs /dev/mmcblk0p1

Using GParted GUI can also be used to specify partition sizes.

note: Steve is available on Discord at discord.vdo.ninja if support with the image is needed

Older image compatible with Jetson A02 with old (original) firmware

The follow Jetson Nano-2GB image, build with Gstreamer 1.19.2, is out of date, but might work on older Jetson boards if problems occur with the newer ones. Requires a large 32-GB SD card or a 64-GB card.

https://drive.google.com/file/d/1WTsW_dWkggGhQXa8p9yOIz3E4tYcl6ee/view?usp=sharing

The username and password to sign in to the image is:

username: ninja
password: vdo

If these images don’t work for your nano, you can update your firmware using another system running Ubuntu 18 /w Jetpack 4 installed I think.

Older image compatible built on a Jetson Xavier NX with old firmware

This is another old image, built on the Xavier NX. Try a newer image before giving this a go.

https://drive.google.com/file/d/1gMB4CDnnbFmIhsbYMqrAjluhn7oS7a03/view?usp=sharing

The username and password to sign in to the image is:

username: ninja
password: vdo

Once you have logged in

Once you have logged in, at the terminal you can download the repo by running:

git clone https://github.com/steveseguin/raspberry_ninja/

If you flashed one of the pre-built images and just want the latest code, run:

sudo rm -r raspberry_ninja
git clone https://github.com/steveseguin/raspberry_ninja
cd raspberry_ninja/installers/nvidia_jetson
./quick_update.sh

Nvidia provided builds

The official Nvidia Jetson builds are running Ubuntu 18, with Gstreamer 1.14. This version is too old to run VDO.Ninja correctly, so it’s recommend that at least Gstreamer 1.16 is used. You can use the provided installer.sh script to upgrade the official Nvidia images with a newer Gstreamer version. The installer.sh script expects a FRESH image install and it may need some dependencies tweaks over time.

The link to the official Nvidia images are here: https://developer.nvidia.com/embedded/downloads

After the Jetson is running, you have connect to the Jetson and pull the raspberry_ninja code and finalize the setup.

git clone https://github.com/steveseguin/raspberry_ninja/
cd raspberry_ninja
cd nvidia_jetson
chmod +x installer.sh
sudo ./installer.sh

You may need to babysit the installation, and it could take a couple hours if things go smoothly.

Auto-start service on boot

You can refer to Raspberry Pi service script below for a sample start-up script for the Jetson https://github.com/steveseguin/raspberry_ninja/blob/main/raspberry_pi/raspininja.service

The setup and installation instructions for the start-up script are similar, which can be found here: https://github.com/steveseguin/raspberry_ninja/tree/main/raspberry_pi#setting-up-auto-boot

The follow bits of the service script may need to be modified or removed if you face issues:

User=vdo
Group=vdo
Environment=XDG_RUNTIME_DIR=/run/user/1000
ExecStartPre=vcgencmd get_camera

Autostart helper script

For the pre-built Jetson image you can configure Raspberry Ninja to launch automatically at boot with an interactive helper:

cd ~/raspberry_ninja/installers/nvidia_jetson
sudo ./setup_autostart.sh

It will:

At the end it prints reminders on how to reboot, start/stop the service manually, or re-enable the GUI later (sudo systemctl set-default graphical.target, sudo systemctl start gdm, etc.).

Details on Nvidia’s Gstreamer implementation

Details on the Nvidia encoder and pipeline options: https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/accelerated_gstreamer.html#wwpID0E0A40HA

image

image

PROBLEMS

Just doens’t work

If you have an error or things just don’t work, saying “START PIPE” but nothing happens, make sure the correct device is specified

video0 or video1 or whatever should align with the location of your video device.
PIPELINE_DESC = "v4l2src device=/dev/video1 io-mode=2 ! image/jpeg,framerate ...

Using $ gst-device-monitor-1.0 can help you list available devices and their location

image

other problems

Make sure the camera/media device supports MJPEG output, else see the script file for examples of other options. Things may not work if your device needs be changed up, but MJPEG is pretty common.

nvjpegdec not found

Make sure you’ve correctly installed the install script or that you have moved the nvidia-provided gstreamer plugins into the correct folder. The Nvidia version of Raspberry Ninja is currently for the Jetson; not desktops.

Updating firmware on Jetson Nano

The Jetson Nanos 4GB 2GB version dev kits may need their firmware updated for newer images to work with them. They are also not getting support much from Nvidia anymore, with Jetpack 4 being the last supported Nvidia software update I think

Updating requires a system (or VM) running Ubuntu 18, with Nvidia Jetpack 4 installed. The process of flashing may take a couple hours, but its worth it.

2GB and 4GB images seem to be mostly compatible once firmware has been updated.