# Using Gstreamer with video encoder/decoder accelerators

**URL:** <https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782>\
**Category:** Product support\
**Created:** [May 8, 2019, 8:49pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782 "2019-05-08T20:49:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farzad](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Farzad](https://forums.balena.io/u/Farzad)\
**Post date:** [May 8, 2019, 8:49pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/1 "2019-05-08T20:49:18Z")

</div>

Hello,

I am trying to get Video encoder/decoder to work with Gstreamer in container on Jetson TX2. I have installed Gstreamer following their documents,

```
add-apt-repository universe
add-apt-repository multiverse
apt-get update
apt-get install gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-
plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
gstreamer1.0-plugins-ugly gstreamer1.0-libav
apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-
dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev

```

Gstreamer with h.264 encoder works fine on CPU,

`gst-launch-1.0 videotestsrc ! 'video/x-raw, format=(string)I420,width=(int)640, height=(int)480' ! x264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink location=test.mp4 -e`

however, on HW accelerator it doesn’t work,

```
gst-launch-1.0 videotestsrc ! 'video/x-raw, format=(string)I420,width=(int)640, height=(int)480' ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink location=test.mp4 -e
WARNING: erroneous pipeline: no element "omxh264enc"

```

The libgstomx.so is installed on /usr/lib/aarch64-linux-gnu/gstreamer-1.0 but gstreamer cannot use gst-omx and the following command returns nothing,

`gst-inspect-1.0 | grep omx`

Does anyone know how to enable video accelerators on Jetson tx2?

---

<div class="post-metadata">

**Author:** ![shaunmulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/shaunmulligan/32/34_2.png) [@shaunmulligan](https://forums.balena.io/u/shaunmulligan)\
**Post date:** [May 8, 2019, 9:05pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/4 "2019-05-08T21:05:57Z")

</div>

Hi there @Farzad . I haven’t tried this myself, could you link to the document/tutorial you have been following. I would also maybe try install the packages for gstreamer we have in this tx2 sample project: [https://github.com/balena-io-playground/tx2-sample-app/blob/master/Dockerfile#L101](https://github.com/balena-io-playground/tx2-sample-app/blob/master/Dockerfile#L101)

---

<div class="post-metadata">

**Author:** ![Farzad](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Farzad](https://forums.balena.io/u/Farzad)\
**Post date:** [May 9, 2019, 10:47pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/7 "2019-05-09T22:47:12Z")

</div>

Hi @shaunmulligan , I tried the sample project. It had some error and I added the libraries and packages into my dockefile. Gstreamer still does not work with HW accelerators and gst-inspect returns the following error,

```
    root@test:/#gst-inspect-1.0 --version

(gst-plugin-scanner:190): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideocuda.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:190): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvivafilter.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:190): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstomx.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:190): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libnvgstjpeg.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:190): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvegltransform.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:190): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnveglglessink.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:190): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideosink.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:190): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstgtksink.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:190): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstopengl.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2
gst-inspect-1.0 version 1.8.3
GStreamer 1.8.3
```

---

<div class="post-metadata">

**Author:** ![CameronDiver](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@CameronDiver](https://forums.balena.io/u/CameronDiver)\
**Post date:** [May 10, 2019, 7:11am UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/10 "2019-05-10T07:11:29Z")

</div>

Could you try installing `libdrm2` explicitly? I would have thought this would be brought in with the other packages, but it seems like there can be versioning issues too: [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879508](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879508)

---

<div class="post-metadata">

**Author:** ![Farzad](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Farzad](https://forums.balena.io/u/Farzad)\
**Post date:** [May 14, 2019, 12:08am UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/12 "2019-05-14T00:08:40Z")

</div>

Hi Cameron,  
Thanks for suggestion but it didn’t fix the issue. I am not sure if the following dmesg logs are helpful,

```
[2358.533609] gst-plugin-scan[5588]: unhandled level 2 translation fault (11) at 0x00000000, esr 0x83000006
[2358.543211] pgd = ffffffc1e067d000
[2358.546626] [00000000] *pgd=0000000259a1a003, *pud=0000000259a1a003, *pmd=0000000000000000

[2358.556442] CPU: 3 PID: 5588 Comm: gst-plugin-scan Not tainted 4.4.38-l4t-r28.2+g174510d #2
[2358.564792] Hardware name: quill (DT)
[2358.568461] task: ffffffc1e4daf080 ti: ffffffc101d14000 task.ti: ffffffc101d14000
[2358.575948] PC is at 0x0
[2358.578487] LR is at 0x7fa6079b60
[2358.581810] pc : [<0000000000000000>] lr : [<0000007fa6079b60>] pstate: 00000000
[2358.589204] sp : 0000007fdb439640
[2358.592524] x29: 0000007fdb439640 x28: 0000000000000001 
[2358.597860] x27: 0000000000000093 x26: 0000000000000093 
[2358.603193] x25: 0000000000000000 x24: 0000000000000001 
[2358.608543] x23: 0000007fa320c878 x22: 0000007fdb43a4a0 
[2358.613878] x21: 0000007fdb43a488 x20: 0000000000000002 
[2358.619212] x19: 0000000000000001 x18: 000000000044fcc0 
[2358.624554] x17: 0000007fa5d2fa40 x16: 0000007fa10f6528 
[2358.629885] x15: 0000000000000061 x14: 0000000000000075 
[2358.635219] x13: 000000000000006c x12: 0000000000000077 
[2358.640559] x11: 0000000000000000 x10: 0101010101010101 
[2358.645892] x9 : 0000000000000042 x8 : 0000000000000060 
[2358.651225] x7 : 0000007fa10d9ee4 x6 : 000000000000002f 
[2358.656573] x5 : 0000000000500f00 x4 : 0000000000000000 
[2358.661911] x3 : 0000007fa30e1dc0 x2 : 0000007fdb43a4a0 
[2358.667244] x1 : 0000007fdb43a488 x0 : 0000000000000002 

[2358.674083] Library at 0x7fa6079b60: 0x7fa606c000 /lib/aarch64-linux-gnu/ld-2.23.so
[2358.681739] vdso base = 0x7fa6097000
```

---

<div class="post-metadata">

**Author:** ![CameronDiver](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@CameronDiver](https://forums.balena.io/u/CameronDiver)\
**Post date:** [May 14, 2019, 1:13pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/13 "2019-05-14T13:13:39Z")

</div>

The problem here appears to be that your libdrm library has a versioning mismatch than is expected, and doesn’t provide `drmGetDevice2` - can you try running `ldd /usr/lib/aarch64-linux-gnu/libgbm.so.1 | grep -i drm` from inside the container, and it might reveal something helpful.

---

<div class="post-metadata">

**Author:** ![Farzad](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Farzad](https://forums.balena.io/u/Farzad)\
**Post date:** [May 14, 2019, 8:48pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/15 "2019-05-14T20:48:59Z")

</div>

Hi @CameronDiver

```
root@3d6c4a4:/# ldd /usr/lib/aarch64-linux-gnu/libgbm.so.1 | grep -i drm 
        libdrm.so.2 => /usr/lib/aarch64-linux-gnu/tegra/libdrm.so.2 (0x0000007f87e77000)

```

Please let me know if you need any more information. I can also grant support access if you want.

---

<div class="post-metadata">

**Author:** ![chrisys](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/chrisys/32/1731_2.png) [@chrisys](https://forums.balena.io/u/chrisys)\
**Post date:** [May 14, 2019, 10:49pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/16 "2019-05-14T22:49:39Z")

</div>

Thanks for getting back to us, it’s always good to enable support access if you could, then when @camerondiver or @shaunmulligan come online again they’ll hopefully be able to take a look.

---

<div class="post-metadata">

**Author:** ![Farzad](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Farzad](https://forums.balena.io/u/Farzad)\
**Post date:** [May 15, 2019, 4:12pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/18 "2019-05-15T16:12:26Z")

</div>

Hi @chrisys ,  
Thanks for your support. The support access is enabled on here is the uuid,  
3d6c4a4b6789d98de25d25c788654990  
Please let me know if you need any more information.

---

<div class="post-metadata">

**Author:** ![zrzka](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/zrzka/32/1612_2.png) [@zrzka](https://forums.balena.io/u/zrzka)\
**Post date:** [May 15, 2019, 4:22pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/20 "2019-05-15T16:22:20Z")

</div>

Thanks, looking at the device now.

---

<div class="post-metadata">

**Author:** ![Farzad](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Farzad](https://forums.balena.io/u/Farzad)\
**Post date:** [May 15, 2019, 4:23pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/21 "2019-05-15T16:23:02Z")

</div>

oh cool! thank!

---

<div class="post-metadata">

**Author:** ![zrzka](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/zrzka/32/1612_2.png) [@zrzka](https://forums.balena.io/u/zrzka)\
**Post date:** [May 15, 2019, 6:40pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/22 "2019-05-15T18:40:23Z")

</div>

Still no luck, checked your device and it seems that there’s really some versioning mismatch. Some libs are used from the /usr/lib/aarch64-linux-gnu/ folder, some libs are used from the /usr/lib/aarch64-linux-gnu/tegra folder, etc. Now your device is offline. I started to reproducing it on my device, but didn’t finish yet. I’ll let you know.

---

<div class="post-metadata">

**Author:** ![Farzad](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Farzad](https://forums.balena.io/u/Farzad)\
**Post date:** [May 15, 2019, 6:49pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/23 "2019-05-15T18:49:23Z")

</div>

oh sorry about that! I forgot to tell the team to not touch the device :))  
It is online now!  
Thank you

---

<div class="post-metadata">

**Author:** ![Farzad](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Farzad](https://forums.balena.io/u/Farzad)\
**Post date:** [May 22, 2019, 10:06pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/29 "2019-05-22T22:06:06Z")

</div>

Hi @zrzka ,  
were you able to reproduce the issue on your device?

---

<div class="post-metadata">

**Author:** ![zrzka](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/zrzka/32/1612_2.png) [@zrzka](https://forums.balena.io/u/zrzka)\
**Post date:** [May 23, 2019, 10:26am UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/30 "2019-05-23T10:26:25Z")

</div>

Hi @Farzad,

not yet, I’m sorry. I have a week off (sick wife, taking care of a child) and will have a chance to look at it by the end of the next week.

---

<div class="post-metadata">

**Author:** ![Farzad](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Farzad](https://forums.balena.io/u/Farzad)\
**Post date:** [May 23, 2019, 4:13pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/31 "2019-05-23T16:13:39Z")

</div>

Hi @zrzka,

Sorry to hear that. I hope everything goes well on your side.

---

<div class="post-metadata">

**Author:** ![zrzka](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/zrzka/32/1612_2.png) [@zrzka](https://forums.balena.io/u/zrzka)\
**Post date:** [May 30, 2019, 1:19pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/40 "2019-05-30T13:19:53Z")

</div>

Hi @Farzad,

I was able to reproduce your issue. I followed all steps of the tx2-sample-app project and got the _same_ issue. Slightly different, but basically the same one.

```auto
root@cbc6fcb9e49a:/# LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/tegra gst-inspect-1.0 /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstomx.so

(gst-inspect-1.0:7481): GStreamer-WARNING **: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstomx.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice
Could not load plugin file: Opening module failed: /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice

```

There’s something fishy with these libraries. I’ll continue with my investigation on Monday morning.

---

<div class="post-metadata">

**Author:** ![zrzka](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/zrzka/32/1612_2.png) [@zrzka](https://forums.balena.io/u/zrzka)\
**Post date:** [June 3, 2019, 10:50am UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/42 "2019-06-03T10:50:06Z")

</div>

Hi @Farzad,

spent some time on this issue today, but still no luck. Except the fact that I run out of space on the device and had to delete lot of stuff.

---

<div class="post-metadata">

**Author:** ![afitzek](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/afitzek/32/359_2.png) [@afitzek](https://forums.balena.io/u/afitzek)\
**Post date:** [June 3, 2019, 2:58pm UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/44 "2019-06-03T14:58:49Z")

</div>

Hi @Farzad,  
This problem needs deeper investigation from our site. I forwarded the problem to our devices team, which will look into this. They will update this thread once they find more information.

---

<div class="post-metadata">

**Author:** ![acostach](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@acostach](https://forums.balena.io/u/acostach)\
**Post date:** [June 20, 2019, 9:38am UTC](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782/46 "2019-06-20T09:38:25Z")

</div>

Hi @Farzad,

I did some searching on the nvidia forums and put together a Dockerfile which builds gstomx from sources for L4T 28.2: [Dockerfile.gstomx](https://github.com/balena-io-playground/tx2-sample-app/blob/omx_build/Dockerfile.gstomx)

If gstomx is built from sources gstreamer is able to load those elements and use them:

```
omx: nvoverlaysink: OpenMax Video Sink
omx: omxvp9enc: OpenMAX VP9 Video Encoder
omx: omxvp8enc: OpenMAX VP8 Video Encoder
omx: omxh265enc: OpenMAX H.265 Video Encoder
omx: omxh264enc: OpenMAX H.264 Video Encoder
....
omx: omxh265dec: OpenMAX H.265 Video Decoder
omx: omxh264dec: OpenMAX H.264 Video Decoder
omx: omxmpeg4videodec: OpenMAX MPEG4 Video Decoder

```

Using nvoverlaysink I can also see video on HDMI:

```
root@90ea535:/# gst-launch-1.0 videotestsrc ! 'video/x-raw, format=(string)I420,width=(int)640, height=(int)480' ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! omxh264dec ! nvoverlaysink -e
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Framerate set to : 30 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
===== MSENC blits (mode: 1) into tiled surfaces =====
NvMMLiteOpen : Block : BlockType = 261 
TVMR: NvMMLiteTVMRDecBlockOpen: 7647: NvMMLiteBlockOpen 
NvMMLiteBlockCreate : Block : BlockType = 261 
TVMR: cbBeginSequence: 1179: BeginSequence 640x480, bVPR = 0
TVMR: LowCorner Frequency = 100000 
TVMR: cbBeginSequence: 1529: DecodeBuffers = 17, pnvsi->eCodec = 4, codec = 0 
TVMR: cbBeginSequence: 1600: Display Resolution : (640x480) 
TVMR: cbBeginSequence: 1601: Display Aspect Ratio : (640x480) 
TVMR: cbBeginSequence: 1669: ColorFormat : 5 
TVMR: cbBeginSequence:1683 ColorSpace = NvColorSpace_YCbCr601
TVMR: cbBeginSequence: 1809: SurfaceLayout = 3
TVMR: cbBeginSequence: 1902: NumOfSurfaces = 24, InteraceStream = 0, InterlaceEnabled = 0, bSecure = 0, MVC = 0 Semiplanar = 1, bReinit = 1, BitDepthForSurface = 8 LumaBitDepth = 8, ChromaBitDepth = 8, ChromaFormat = 5
TVMR: cbBeginSequence: 1904: BeginSequence ColorPrimaries = 2, TransferCharacteristics = 2, MatrixCoefficients = 2
Allocating new output: 640x480 (x 24), ThumbnailMode = 0
OPENMAX: HandleNewStreamFormat: 3464: Send OMX_EventPortSettingsChanged : nFrameWidth = 640, nFrameHeight = 480 
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
TVMR: FrameRate = 30 
TVMR: NVDEC LowCorner Freq = (100000 * 1024) 

```

With this I can also see MSENC and NVDEC hw encoding/decoding engines kicking in.

[Next page](https://forums.balena.io/t/using-gstreamer-with-video-encoder-decoder-accelerators/7782.md?page=2)
