title: Gstreamer, Docker, udpsrc, OpenCV, Python... Not working
body: <p>I am pretty new (only two days old) in the whole streaming and capture world. What I am trying to do is to capture a video stream from a UDP port using OpenCV and Python. I want my script to run inside a Docker container. I have created a docker container based on Fedora and installed Python3.6.5, OpenCV in it. The OpenCV has been compiled from source with the following options - </p>
  
  <pre><code>cmake -DBUILD_TIFF=ON \
      -DBUILD_WEBP=ON \
      -DBUILD_opencv_java=OFF \
      -DWITH_CUDA=OFF \
      -DENABLE_AVX=ON \
      -DWITH_OPENGL=ON \
      -DWITH_OPENCL=ON \
      -DWITH_IPP=ON \
      -DWITH_TBB=ON \
      -DWITH_GSTREAMER=ON \
      -DWITH_EIGEN=ON \
      -DWITH_V4L=ON \
      -DBUILD_TESTS=OFF \
      -DBUILD_PERF_TESTS=OFF \
      -DCMAKE_BUILD_TYPE=RELEASE \
      -DCMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") \
      -DPYTHON_EXECUTABLE=$(which python) \
      -DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
      -DPYTHON_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
      -DWITH_FFMPEG=ON \
      -DWITH_GTK_2_X=ON \
      -DBUILD_PNG=ON \
      -DBUILD_JASPER=ON \
      -DBUILD_JPEG=ON \
      -DWITH_V4L=ON .. \
  </code></pre>
  
  <p>I have checked the UDP port using the following command - </p>
  
  <pre><code>tcpdump -i lo -n udp port &lt;port_number&gt;
  </code></pre>
  
  <p>It seems that it is receiving packets properly. No problem in that.</p>
  
  <p>I have the following script inside my container to read frames from the udpsrc </p>
  
  <pre><code>import cv2
  
  gst_string = "udpsrc port=&lt;port_number&gt; caps=\"application/x-rtp, media=(string)video, clock-rate=(int)90000\" ! rtpvp8depay ! vp8dec ! videoconvert ! appsink"
  
  video_capture = cv2.VideoCapture(gst_string)
  
  while video_capture.isOpened():
      ret, frame = video_capture.read()
      print("Frame received {}".format(ret))
  </code></pre>
  
  <p>And I am starting my docker container using the following command - </p>
  
  <pre><code>docker run -it -p &lt;port_number&gt;:&lt;port_number&gt;/udp myworker /bin/bash
  </code></pre>
  
  <p>And finally when from the bash prompt I am starting the script using <code>python worker.py</code> it is not going into the loop as the <code>video_capture.isOpened()</code> is returning False. </p>
  
  <p>I have very little experience to all the things involved here (apart from Python and to some extent Docker) so I am unable to find out what I am doing wrong. Please help me.</p>
  
  <p>Thanks in advance</p>
  
  <p>EDIT ----------------</p>
  
  <p>For further info, I had installed the following plugings to gstreamer - </p>
  
  <pre><code>yum install -y libnice-gstreamer1 \
      gstreamer-plugins-good \
      gstreamer1-plugins-ugly \
      gstreamer1-plugins-good \
      gstreamer-plugins-bad-free-extras \
      gstreamer-plugins-espeak gstreamer \
      gstreamer1 \
      gstreamer1-plugins-base-tools \
      gstreamer1-plugins-bad-free-extras \
      gstreamer1-plugins-bad-freeworld \
      gstreamer-plugins-bad-free \
      gstreamer1-plugins-base \
      gstreamer1-plugins-good-extras \
      gstreamer-plugins-base gstreamer-tools \
      PackageKit-gstreamer-plugin \
      gstreamer1-plugins-bad-free
  </code></pre>
  
  <p>EDIT -2 ---------------------------------</p>
  
  <p>As mentioned in the comments, the OpenCV i was using did not have Gstreamer compiled inside it. So I was not able to open the Videocapture. So the <code>yum</code> command from above eventually becomes - </p>
  
  <pre><code>RUN yum install -y libnice-gstreamer1 \
      gstreamer1-plugins-ugly \
      gstreamer1-plugins-good \
      gstreamer1 \
      gstreamer1-plugins-base-devel \
      gstreamer-plugins-base-tools \
      gstreamer1-plugins-bad-free-extras \
      gstreamer1-plugins-bad-freeworld \
      gstreamer1-plugins-base \
      gstreamer1-plugins-good-extras \
      gstreamer1-plugins-base \
      gstreamer1-plugins-bad-free \
      gstreamer-plugins-base-devel
  </code></pre>
  
  <p>Et voila! This did the trick.</p>