Search by Tags

How to: Using Gstreamer in a Docker Container with Torizon

 
Applicable for

Article updated at 02 Jan 2020
Subscribe for this article updates

Introduction

Torizon platform features Docker runtime. Toradex provides Debian Docker images and deb packages that greatly eases the development process for embedded applications. In this article, we will show how you can run Gstreamer in a container with Torizon.

Warning: Currently only plugins from the Gstreamer project repository are available. A Debian package with VPU accelerated Gstreamer plugins for i.MX will be available soon. Please contact your Toradex representative if you need more information about this plugin.

Typographic Conventions

Prerequisites

  • A Toradex's SoM with Torizon installed ( To get instructions about how to install Torizon, see Getting Started Guide )
  • Basic knowledge of Docker containers. To learn more about Docker, visit the developer's website. To learn the first steps with Docker usage and Torizon, check the Getting Started Guide.

Dockerfile instructions

Download the full Dockerfile implementation.The implementation details will be explained in this session. See the Getting Started Guide with the instructions about how to compile the image on a host pc and pull the image in the board. You can also scp this file to the board and build it locally.

To build

On the host PC, build the image:

$ docker build -t <your-dockerhub-username>/gst_torizon_example .

After the build, push the image to your Dockerhub account:

$ docker push <your-dockerhub-username>/gst_torizon_example

To run

First, pull it from your dockerhub account to the board. In the terminal of your board:

# docker pull <your-dockerhub-username>/gst_torizon_example

After the pull, run a container based on the image.

Attention: Please, note that by executing the following line you are accepting the NXP's terms and conditions of the End-User License Agreement (EULA)

# docker run -e ACCEPT_FSL_EULA=1 -d --rm --name=gst-container --net=host -v /dev/galcore:/dev/galcore -v /dev:/dev -v /tmp:/tmp -v /run/udev/:/run/udev/ --privileged gst_torizon_example --developer weston-launch --tty=/dev/tty7 --user=torizon

Details about the Dockerfile

Toradex Debian image - Wayland

Toradex provides a basic Wayland image in its dockerhub page. If you are using an iMX8 (arm64v8 CPU) computer-on-module (COM) add torizon/arm64v8-debian-wayland-base-vivante to your image. Otherwise, select torizon/arm32v7-debian-wayland-base. It contains the repository package.

FROM torizon/arm64v8-debian-wayland-base-vivante
FROM torizon/arm32v7-debian-wayland-base

Install Gstreamer application and plugins

Install the required packages on the image with the following commands:

RUN apt update
RUN apt install -y libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio

Test gstreamer

We will test Gstreamer as entrypoint for our dockerfile. A test source pattern will be output to a Wayland window. You can modify the pipeline for your needs

ENTRYPOINT gst-launch-1.0 videotestsrc ! videoconvert ! videoscale ! waylandsink sync=false

Complete Dockerfile

You can Download the full Dockerfile implementation, or copy from the block below:

Dockerfile
FROM torizon/arm64v8-debian-weston-vivante:buster
 
RUN apt-get -y update && apt-get install -y \
	libgstreamer1.0-0 \
	gstreamer1.0-plugins-base \
	gstreamer1.0-plugins-good \
	gstreamer1.0-plugins-bad \
	gstreamer1.0-plugins-ugly \
	gstreamer1.0-libav \
	gstreamer1.0-doc \
	gstreamer1.0-tools \
	gstreamer1.0-x \
	gstreamer1.0-alsa \
	gstreamer1.0-gl \
	gstreamer1.0-gtk3 \
	gstreamer1.0-qt5 \
	gstreamer1.0-pulseaudio
	&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
 
CMD gst-launch-1.0 videotestsrc ! videoconvert ! videoscale ! waylandsink sync=false
Dockerfile
FROM torizon/arm32v7-debian-wayland-base
 
RUN apt-get -y update && apt-get install -y \
	libgstreamer1.0-0 \
	gstreamer1.0-plugins-base \
	gstreamer1.0-plugins-good \
	gstreamer1.0-plugins-bad \
	gstreamer1.0-plugins-ugly \
	gstreamer1.0-libav \
	gstreamer1.0-doc \
	gstreamer1.0-tools \
	gstreamer1.0-x \
	gstreamer1.0-alsa \
	gstreamer1.0-gl \
	gstreamer1.0-gtk3 \
	gstreamer1.0-qt5 \
	gstreamer1.0-pulseaudio
	&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
 
CMD gst-launch-1.0 videotestsrc ! videoconvert ! videoscale ! waylandsink sync=false