# Nvidia Jetson devices



## KA5BBC (Sep 25, 2020)

I have seen multiple videos, posts, and comments that people have successfully got OBS running on Nvidia Jetson Nano devices but I cannot find any instructions on how to go about doing this.
Does anyone have a set of instructions, preferably for the less Linux / Tech savvy?
My thanks in advance.


----------



## jjlooks (Nov 18, 2020)

Hey,

worked for me:

But i didnt get the Harware Encoder running...still working on this...

sauce: https://qiita.com/kitazaki/items/3950c48a68bab1766fb6


```
sudo apt update

sudo apt upgrade

sudo apt install \

            build-essential \

            checkinstall \

            cmake \

            git \

            libmbedtls-dev \

            libasound2-dev \

            libavcodec-dev \

            libavdevice-dev \

            libavfilter-dev \

            libavformat-dev \

            libavutil-dev \

            libcurl4-openssl-dev \

            libfdk-aac-dev \

            libfontconfig-dev \

            libfreetype6-dev \

            libgl1-mesa-dev \

            libjack-jackd2-dev \

            libjansson-dev \

            libluajit-5.1-dev \

            libpulse-dev \

            libqt5x11extras5-dev \

            libspeexdsp-dev \

            libswresample-dev \

            libswscale-dev \

            libudev-dev \

            libv4l-dev \

            libvlc-dev \

            libx11-dev \

            libx264-dev \

            libxcb-shm0-dev \

            libxcb-xinerama0-dev \

            libxcomposite-dev \

            libxinerama-dev \

            pkg-config \

            python3-dev \

            qtbase5-dev \

            libqt5svg5-dev \

            swig \

            libxcb-randr0-dev \

            libxcb-xfixes0-dev \

            libx11-xcb-dev \

            libxcb1-dev
```

Followed by:


```
git clone --recursive https://github.com/obsproject/obs-studio.git
```


```
cd obs-studio
mkdir build && cd build
cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo make install
```

Start OBS with:


```
sudo LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libGL.so obs
```


----------



## muzker (Feb 20, 2021)

Hey,

this looks really promising. Where you already able to integrate the hardware encoder to your setup?
What are your impressions due to the streaming performance?

Cheers,
Muzker


----------



## Tuna (Feb 20, 2021)

It has been reported that the hardware encoder was usable via the 3rd party GStremaer plugin.


----------



## muzker (Mar 2, 2021)

For me,

```
sudo apt-get install qtbase5-private-dev
```
was also required to build.


----------



## avico (Mar 18, 2021)

anyone could use jetson's hardwares encoders with obs?
Please tell how.
Thanks.


----------



## sa7bnt (Mar 18, 2021)

After i reinstall OBS on my Jetson Nano 4GB im running in to that issue. 


> info: ---------------------------------
> info: Initializing OpenGL... Segmentation fault


That issue comes up if i start OBS from terminal "sudo obs" or just "obs"
If i try to start like 





> "sudo LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libGL.so" or lust "LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libGL.so"


OBS will not start. The terminal will just hop one line down without doing something. 
Someone know that issue??


----------



## tom8servo (Mar 19, 2021)

jjlooks said:


> Hey,
> 
> worked for me:
> 
> ...




Thanks for this, I was able to get OBS running on a Nano B01.  Had to add
sudo apt-get install qtbase5-private-dev to the build, otherwise the make output shows errors due to this being missing.

I see you have been working on adding hardware encoders.  I have built ffmpeg following kitazaki's instructions, but while it builds successfully, I am not able to test this to ensure operability.  Moreover, I have seen oblique references to '3rd party' gstreamer use, and what research I have done reveals a build of this for Nano is going to be a bit complicated.  I know NVidia has a gstreamer implementation, as well.  Do you know of anyone successfully using these encoders with OBS on Nano?  It would be a welcome addition to this thread.  I am interested in possibly using a Nano running OBS, but I am also looking for NDI facilities.  This would be my second question: anyone know of an NDI runtime build for Nano?


----------



## neatspace (Mar 26, 2021)

Also glad to report I got OBS running on a new Nano last night thanks to all the contributors here :)  Gonna take a shot at Gstreamer this weekend to get hardware encoding.

On a related note....since Browser source is unavailable in this build, I'm using Media Source, unchecking the local file option, and using https links to my mp4s online.  See the screenshot attached for an example of an https Media Source video that's working

To make them loop, though, do I have to write an html file with the video url and a meta refresh header tag, then set that as the source?  Will the Media Source even accept an html file in this build on the Nano? 

Before I try that, is there any way to make an https Media Source refresh the video automatically?  OBS has to call to call the video to play when it initiates, so why not call the video again automatically after each play?


----------



## neatspace (Mar 27, 2021)

I asked on the Discord and they said Media Source can't render html :(  How hard would it be to add Browser Source to this build for the Jetson?


----------



## Tuna (Mar 27, 2021)

tom8servo said:


> I have seen oblique references to '3rd party' gstreamer use, and what research I have done reveals a build of this for Nano is going to be a bit complicated.


Can you elaborate? It should be as "complicated" as any other Linux.


----------



## tom8servo (Mar 29, 2021)

Tuna said:


> Can you elaborate? It should be as "complicated" as any other Linux.


I suppose I might begin with the query, 'which gstreamer?'  to wit:  google 'gstreamer github'...or, 'github gstreamer arm64 nvidia nano'.  I am not a well practiced Linux devotee, but I could not find a way to the door with either of those attempts to locate an appropriate starting point.  If you have a recommendation that points directly at this need, I would be grateful to know it-  thanks!


----------



## neatspace (Mar 30, 2021)

Kitazaki added a browser source build to the post within a day of me asking!  He hasn't added proprietary video codecs yet, but still big ups to him.

I got Gstreamer 1.14.5 installed through the package manager, but is this plug-in still going to require custom pipelines for every source I want NVENC to encode for OBS?  https://github.com/fzwoch/obs-gstreamer 

Sorry to beat up this thread, my friend that literally works on Nanos just got a new job and moved this week :'(

Alternatively, would this patch allow OBS to use the NVENC without custom pipelines? https://imgur.com/gallery/XqsTDRf
suace: https://gist.github.com/danieloneill/9952820ad3ae0fe36738b4106ae6a775


----------



## Tuna (Mar 30, 2021)

neatspace said:


> I got Gstreamer 1.14.5 installed through the package manager, but is this plug-in still going to require custom pipelines for every source I want NVENC to encode for OBS? https://github.com/fzwoch/obs-gstreamer


You need custom pipeline for sources. Sounds to me you are only interested in the hardware encoder.


----------



## Costor (Mar 30, 2021)

avico said:


> anyone could use jetson's hardwares encoders with obs?
> Please tell how.
> Thanks.


I did it, and I put the description how to do it on github just yesterday :-) .
The jetson does not use the nvenc encoder, but nvmpi.  So I had to pull together various bits and pieces:  nvmpi for ffmpeg and StreamFX.
I also integrated the Browser source.


----------



## Costor (Mar 30, 2021)

neatspace said:


> I asked on the Discord and they said Media Source can't render html :(  How hard would it be to add Browser Source to this build for the Jetson?


As I wrote in the reply above, I've build obs including browser source and hardware encoding support (based on ffmpeg and StreamFX) in the last weeks. I also struggled at the browser source because the instructions  how to build the browser extension were incorrect for arm64 / aarch64 devices like the jetson. 

This is what I ended up doing instead:
1) The key thing is to download the correct "Chrome embedded Framework" for Linux-*arm64* from CEF builds . Make sure you chose the "Linux-ARM64" tab, and the 'minimal distribution' from the 'stable build'  (so not use the download link provided by obs, because that is for amd64 architecture - not helpful on an arm64 device)
2) unpack it (using tar -xjf) to a directory of your choosing, e.g. ~/CEF-bin-min
3) cd CEF-bin-min  && mkdir build && cd build
4) the cmake statement needs to be extended by the architecture option:  
cmake -G "Unix Makefiles" -DPROJECT_ARCH="arm64"  -DCMAKE_BUILD_TYPE=Release
5) make -j3 cefsimple       

I than continued with the building steps of obs-studio, see my remarks on this here .


----------



## neatspace (Apr 1, 2021)

Hi Costor :) I built jetson-ffmpeg with your instructions including your compiler flag, but I got this error:

```
$ ffmpeg -i ~/downloads/file_example_MOV_480_700kB.mov -c:v h264_nvmpi test.mp4
ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
/home/neatspace/downloads/file_example_MOV_480_700kB.mov: No such file or directory
```

That file definitely exists in downloads.  Is this related to the conflicts with the standard ffmpeg package?  I don't understand what you mean by "inserting /usr/local/bin at the beginning of the library search path LD_LIBRARY_PATH."

Or is the error something else I'm missing?


----------



## neatspace (Apr 1, 2021)

Oh also, did you check if proprietary video codecs work on the Browser source in your OBS build, or only webm?


----------



## neatspace (Apr 1, 2021)

Tuna said:


> You need custom pipeline for sources. Sounds to me you are only interested in the hardware encoder.


Yes, if I could set OBS to use hardware encoding for everything in its settings, I would be good to go.


----------



## kcsquared (May 24, 2021)

Hi Costor, thanks a ton for your guide on building OBS for the Jetson Nano with browser source and hardware encoding. Using your instructions I've been able to build and run OBS successfully! Albeit, after slogging through some issues with std::filesystem vs std::experimental::filesystem and getting a run-time error for openGL unless I use "$export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libGL.so"

I have built ffmpeg with the hardware encoding patch and tested (see ffmpeg_nvmpi_test_output.txt). I was also able to display browser source when I got OBS running. 

The bad news is that I'm having an issue with the custom StreamFX library, I've included the runtime output of OBS (StreamFX_Load_Failure.txt). As you can see, there is an issue with an undefined symbol in the StreamFX library. I used nm to verify this.

peng@observer:/usr/local$ nm /usr/local/lib/obs-plugins/StreamFX.so | grep _ZTVN8streamfx7encoder6ffmpeg7handler18nvmpi_h264_handlerE
                 U _ZTVN8streamfx7encoder6ffmpeg7handler18nvmpi_h264_handlerE

Running nm with the -C switch to unmangle the symbol I got:  "U vtable for streamfx::encoder::ffmpeg::handler::nvmpi_h264_handler"

I even tried defining an empty body destructor for the class in "nvmpi_h264_handler.cpp", after reading up on some similar issues. I think most of those posters were experiencing compilation errors though.

The strange thing is that the build is successful, but the library is missing symbols.

Any idea where I went wrong?

Thanks!


----------



## Costor (May 25, 2021)

Hi Kcsquared,  
a quick upfront remark: some weeks ago StreamFX had a new release to which my nvmpi encoder files are no longer compatible. The changes made in StreamFX however do not touch the core functionality but deal with online help etc. See my comment here  ‘D_DESC’ was not declared in this scope · Issue #1 · Costor/nvmpi-obs-streamFX (github.com) .

But since you did not mention this you either work on the previous version that I have also used, or have managed to adapt the nvmpi-files. 
If the latter (i.e. you have dealt with the D_DESC issue) you probably have some issue in the nvmpi_h264_handler.cpp/hpp files that prevents the symbol   nvmpi_h264_handler from being declared or exported.

Any way: please check what you made different in the files hvmpi_hevc.handler.cpp/hpp files since you have not got a missing symbol error for nvmpi_hevc_handler.
Beyond that I can only guess:
1) StreamFX requires GCC 9 for a fully compatible C++ . However I've noted that ffmpeg reports GCC 7 for its build. So did you use GCC 9 for StreamFX?
2) You have double checked that there is no other (older) streamFX.so somewhere in the search path? Check LD_LIBRARY_PATH...

Regards, Costor


----------



## kravchenkoandrey (Oct 19, 2021)

Hello!

So, I read the thread and still have some questions) 

Do anybody successfully ran OBS with hardware encoding? What's the performance and heat release? Will 2GB version be enough for streaming?


----------

