from vidgear.gears import CamGear
import cv2
我正在尝试打开从某个网站进行实时流式传输的视频,例如('https://c.streamhoster.com/embed/media/O7sB36/6WW26anes7e/KmhtPuscTUZ_5')。不幸的是,它们被嵌入并使用cv2.VideoCapture和CamGear(URL).start()打开时出错。错误是:
>>> 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!
我正在尝试找到方法或技巧,以便可以使用以下库或任何其他库来加载它们。 最佳答案
我是VidGear库的作者。我认为https://c.streamhoster.com/embed/media/O7sB36/6WW26anes7e不是有效的媒体格式,而是嵌入式HTML5格式。甚至FFmpeg也拒绝播放它:
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
由于VidGear甚至OpenCV都可以在FFmpeg后端上使用,因此您将无法播放它。关于python - 在OpenCV VideoCapture或Vidgear中访问/打开嵌入式视频,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62617929/