feed_me_pi
feed_me_pi

Reputation: 177

Access/Open embedded videos in OpenCV VideoCapture or Vidgear

from vidgear.gears import CamGear
import cv2

I am trying to open the videos which are live streaming from a website for example ('https://c.streamhoster.com/embed/media/O7sB36/6WW26anes7e/KmhtPuscTUZ_5'). Unfortunately, they are embedded and giving error while opening using cv2.VideoCapture and CamGear(URL).start()

The error is:

>>> cap = cv2.VideoCapture(url)
OpenCV: Couldn't read video stream from file "https://c.streamhoster.com/embed/media/O7sB36/6WW26anes7e/KmhtPuscTUZ_5"

>>> cap = CamGear(source=url, y_tube=flag, **options).start()
OpenCV: Couldn't read video stream from file "https://c.streamhoster.com/embed/media/O7sB36/6WW26anes7e/KmhtPuscTUZ_5"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/vidgear/gears/camgear.py", line 214, in __init__
    "[CamGear:ERROR] :: Source is invalid, CamGear failed to intitialize stream on this source!"
RuntimeError: [CamGear:ERROR] :: Source is invalid, CamGear failed to intitialize stream on this source!

I am trying to find ways or tricks so that they can be loaded using the following libraries or any other library.

Upvotes: 0

Views: 503

Answers (1)

abhiTronix
abhiTronix

Reputation: 1402

I'm the author of VidGear library. I don't think https://c.streamhoster.com/embed/media/O7sB36/6WW26anes7e is a valid media format, and rather a embed HTML5 format. Even FFmpeg refused to play it:

ffplay -i https://c.streamhoster.com/embed/media/O7sB36/6WW26anes7e/KmhtPuscTUZ_5
ffplay version 3.4.8-0ubuntu0.2 Copyright (c) 2003-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-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
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-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 --enable-version3 --disable-doc --disable-programs --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
  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
https://c.streamhoster.com/embed/media/O7sB36/6WW26anes7e/KmhtPuscTUZ_5: Invalid data found when processing input

Since VidGear and even OpenCV works on FFmpeg backend, you won't be able to play it.

Upvotes: 1

Related Questions