Docker Community Forums

Share and learn in the Docker community.

Video stream in-out via docker

I am new to Docker and want to do some video processing inside a docker container , now I want to stream a video from host to docker container where it will be processed and then it will again be sent out in any form and received by HOST.
I have started with GSTREAMER with UDP which will send my video to container but I cant figure it out.

Any help would be appreciated.

First, you need to give an interpreter for executing the script.

Second, you can’t run vlc as root.

Third, you can’t provide a file as argument and expect vlc to open it from inside the container, when the file is on the host. You need to mount it first.

Fourth, you need to quote $sout variable, otherwise it will begin with # and bash will ignore it as an argument and won’t pass it to vlc.

Fifth, if you want the stream to be available outside, you will need to expose the port.

Make the following changes:

Dockerfile:

FROM ubuntu

RUN apt-get update
&& apt-get install -y vlc

RUN useradd -m vlcuser

COPY simulate_video_stream.sh /tmp/
COPY counter.mp4 /tmp/
ENTRYPOINT ["/tmp/simulate_video_stream.sh"]
Script simulate_video_stream.sh:

#!/bin/bash

Two facultativ parameters : -f and -i <URL_Output>

SCRIPTPATH=( cd (dirname $0) ; pwd -P );
name=$SCRIPTPATH"/counter.mp4";
sdp=“rtsp://:8554/flux”;
while getopts “f:i:” OPTNAME
do
case $OPTNAME in
f) name=$OPTARG;;
i) sdp=$OPTARG;;
esac
done
sout="#transcode{vb=0,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:rtp{sdp="$sdp"}";
su vlcuser -c “vlc -vvv $name --sout ‘$sout’”
And run the container as:

docker run -v $PWD/namevideo.mp4:/tmp/namevideo.mp4 -p 8554:8554 test -f /tmp/namevideo.mp4