我正在尝试捕获相机直播流并从中制作HLS流。我使用的是Fantech Luminous C30网络摄像头。我得到这个错误:
ERROR:root:ffmpeg failed to execute command: b'ffmpeg version 2022-12-11-git-c3e20f78b0-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developersrn built with gcc 12.1.0 (Rev2, Built by MSYS2 project)rn
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprintrn libavutil 57. 43.100 / 57. 43.100rn libavcodec 59. 55.100 / 59. 55.100rn libavformat 59. 34.102 / 59. 34.102rn libavdevice 59. 8.101 / 59. 8.101rn libavfilter 8. 52.100 / 8. 52.100rn libswscale 6. 8.112 / 6. 8.112rn libswresample 4. 9.100 / 4. 9.100rn libpostproc 56. 7.100 / 56. 7.100rnFantech Luminous C30: No such file or directoryrn'
Traceback (most recent call last):
File "c:UsersltadicDesktophls streamcamera_stream.py", line 12, in <module>
hls.output('C:\Users\ltadic\Desktop\camera_stream\hls.m3u8')
File "C:UsersltadicAppDataLocalProgramsPythonPython311Libsite-packagesffmpeg_streaming_media.py", line 93, in output
self.run(ffmpeg_bin, monitor, **options)
File "C:UsersltadicAppDataLocalProgramsPythonPython311Libsite-packagesffmpeg_streaming_media.py", line 121, in run
asyncio.run(self.async_run(ffmpeg_bin, monitor, **options))
File "C:UsersltadicAppDataLocalProgramsPythonPython311Libasynciorunners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:UsersltadicAppDataLocalProgramsPythonPython311Libasynciorunners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersltadicAppDataLocalProgramsPythonPython311Libasynciobase_events.py", line 650, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:UsersltadicAppDataLocalProgramsPythonPython311Libsite-packagesffmpeg_streaming_media.py", line 112, in async_run
self._run(ffmpeg_bin, monitor, **options)
File "C:UsersltadicAppDataLocalProgramsPythonPython311Libsite-packagesffmpeg_streaming_media.py", line 106, in _run
self.pipe, err = process.run()
^^^^^^^^^^^^^
File "C:UsersltadicAppDataLocalProgramsPythonPython311Libsite-packagesffmpeg_streaming_process.py", line 122, in run
raise RuntimeError('ffmpeg failed to execute command: ', error)
RuntimeError: ('ffmpeg failed to execute command: ', "b'ffmpeg version 2022-12-11-git-c3e20f78b0-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers\r\n built with gcc 12.1.0 (Rev2, Built by MSYS2 project)\r\n configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint\r\n libavutil 57. 43.100 / 57. 43.100\r\n libavcodec 59. 55.100 / 59. 55.100\r\n libavformat 59. 34.102 / 59. 34.102\r\n libavdevice 59. 8.101 / 59. 8.101\r\n libavfilter 8. 52.100 / 8. 52.100\r\n libswscale
6. 8.112 / 6. 8.112\r\n libswresample 4. 9.100 / 4. 9.100\r\n libpostproc 56. 7.100 / 56. 7.100\r\nFantech Luminous C30: No such file or directory\r\n'")
这是我的代码:
import ffmpeg_streaming
from ffmpeg_streaming import Formats,Bitrate, Representation, Size
video = ffmpeg_streaming.input('Fantech Luminous C30', capture = True)
_360p = Representation(Size(640, 360), Bitrate(276 * 1024, 128 * 1024))
_480p = Representation(Size(854, 480), Bitrate(750 * 1024, 192 * 1024))
_720p = Representation(Size(1280, 720), Bitrate(2048 * 1024, 320 * 1024))
hls = video.hls(Formats.h264())
hls.representations(_360p, _480p, _720p)
hls.output('C:\Users\ltadic\Desktop\camera_stream\hls.m3u8')
似乎FFmpeg在试图从您的网络摄像头捕获视频时报告了一个错误。错误信息"Fantech Luminous C30: No such file or directory"中给出的网络摄像头的路径或名称可能有问题。出现此错误的一个可能原因是FFmpeg无法找到网络摄像头。确保网络摄像头已连接到您的计算机,并安装了网络摄像头的驱动程序。确保FFmpeg使用正确的网络摄像头。也可能是FFmpeg没有从网络摄像头捕获视频所需的编解码器或库。确保正确配置和编译了FFmpeg,并且提供了所有必需的库。您是否尝试使用其他应用程序打开您的网络摄像头?