使用vlc -I qt a.mp4 '#http{mux=ffmpeg{mux=mp4},dst=:8080/stream}' --sout-all --sout-keep
视频可以在本地正常播放音频和视频,但我收到一些错误消息:
[00007f01f0004960] gl gl: Initialized libplacebo v4.192.1 (API v192)
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nvidia_drv_video.so
libva info: va_openDriver() returns -1
[00007f01f0004960] glconv_vaapi_x11 gl error: vaInitialize: unknown libva error
libva info: VA-API version 1.14.0
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[00007f01f0004960] glconv_vaapi_drm gl error: vaInitialize: unknown libva error
libva info: VA-API version 1.14.0
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[00007f01f0004960] glconv_vaapi_drm gl error: vaInitialize: unknown libva error
[00007f01f0004960] gl gl: Initialized libplacebo v4.192.1 (API v192)
[00007f022584cdd0] avcodec decoder: Using NVIDIA VDPAU Driver Shared Library 520.61.05 Thu Sep 29 05:28:13 UTC 2022 for hardware decoding
[hevc @ 0x7f0225860680] Failed setup for format vdpau: hwaccel initialisation returned error.
[00007f022584cdd0] avcodec decoder error: existing hardware acceleration cannot be reused
[00007f01f0004960] gl gl: Initialized libplacebo v4.192.1 (API v192)
[00007f01f0004960] gl gl: Initialized libplacebo v4.192.1 (API v192)
该文件看起来不像是正在被流式传输,这nmap 192.168.1.x -p 8080
也证实了:
PORT STATE SERVICE
8080/tcp closed http-proxy
使用 Ubuntu 22.04 和 GTX970。已经安装了 CUDA。
如果我输入客户端,http://192.168.1.x:8080/stream
我会收到“无法播放多种媒体”错误。
按照 Tonny 的建议,我安装了驱动程序更新sudo ubuntu-drivers autoinstall
但仍然得到:
[00007f5ef8004960] gl gl: Initialized libplacebo v4.192.1 (API v192)
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nvidia_drv_video.so
libva info: va_openDriver() returns -1
[00007f5ef8004960] glconv_vaapi_x11 gl error: vaInitialize: unknown libva error
libva info: VA-API version 1.14.0
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[00007f5ef8004960] glconv_vaapi_drm gl error: vaInitialize: unknown libva error
libva info: VA-API version 1.14.0
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[00007f5ef8004960] glconv_vaapi_drm gl error: vaInitialize: unknown libva error
[00007f5ef8004960] gl gl: Initialized libplacebo v4.192.1 (API v192)
[00007f5f24ce6000] avcodec decoder: Using NVIDIA VDPAU Driver Shared Library 515.65.01 Wed Jul 20 13:42:26 UTC 2022 for hardware decoding
automatic
编辑2:在 VLC 输入编解码器设置 -> 硬件加速解码中从 切换到 后,VDPAU video decoder
所有错误消息都消失了,但原来的问题仍然存在
编辑 3:一旦文件停止播放,我收到以下错误:
Your input can't be opened:
VLC is unable to open the MRL 'file:///home/my/path/%23http%7Bmux%3Dffmpeg%7Bmux%3Dmp4%7D%2Cdst%3D%3A8080/stream%7D'.
答案1
好的,首先感谢大家的帮助。每一个里程碑都让我更接近目标!
我发现主要问题出在视频本身,首先必须使其可流式传输才能进行 http 流式传输(创建可用于 HTTP 流式传输的 MP4 视频)!
ffmpeg -i a.mp4 -c:v libx264 -crf 23 -c:a aac -movflags faststart b.mp4
然后让它工作的命令是:
vlc -I qt b.mp4 :sout="#http{mux=ffmpeg{mux=flv},dst=:8080}" :sout-all :sout-keep
在客户端中:
http://192.168.1.x:8080
仍然存在一个小问题,当我已经开始获取音频时,视频在前 3 秒是黑色的,需要弄清楚缓存部分!