ffmpeg - ffplay、rtsp 和 tcp 传输协议(protocol)

标签 ffmpeg

我在使用 ffplay 连接到 rtsp 相机时遇到问题。
摄像机位于仅允许 tcp 协议(protocol)的路由器下。
只有当我在相机的同一网络中时,我才能使用 ffplay 观看相机。
所以,当我出去的时候,使用这个命令行

ffplay rtsp://地址:554/onvif1

或这个

ffplay -rtsp_transport tcp rtsp://address:554/onvif1

我不能看相机。
这是 ffplay 的输出(最新)。

[rtsp @ 059ee680] 服务器回复 0B f=0/0 中的传输不匹配
rtsp://address:554:/onvif1: 处理输入时发现无效数据

尝试使用 vlc 时,无论是在同一个网络中还是外出时,我都可以毫无问题地观看相机。 vlc 输出表明 vlc 使用 tcp。
有人有建议吗?

最佳答案

当然,正如您在下面看到的,vlc 可以正常工作。
FFMpeg 仅适用于本地摄像头,但不适用于远程摄像头。强制 tcp 作为 rtsp 协议(protocol)似乎没有效果。

尝试捕捉远程相机(不起作用)

denis@tomcat:~/Scaricati/ffmpeg-git-20181227-amd64-static$ **./ffmpeg -v verbose -i rtsp://address:554/onvif1 a.avi**
ffmpeg version N-47834-gb5e0a0fe3a-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      56. 25.100 / 56. 25.100
  libavcodec     58. 42.104 / 58. 42.104
  libavformat    58. 25.100 / 58. 25.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[tcp @ 0x5f86700] Starting connection attempt to address port 554

try catch 远程摄像头强制 tcp(不起作用)
denis@tomcat:~/Scaricati/ffmpeg-git-20181227-amd64-static$ **./ffmpeg -v verbose -rtsp_transport tcp -i rtsp://address:554/onvif1 a.avi**
ffmpeg version N-47834-gb5e0a0fe3a-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      56. 25.100 / 56. 25.100
  libavcodec     58. 42.104 / 58. 42.104
  libavformat    58. 25.100 / 58. 25.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[tcp @ 0x5515740] Starting connection attempt to address port 554

使用 vlc (作品)
denis@tomcat:~/Scaricati/ffmpeg-git-20181227-amd64-static$ **vlc -v**
VLC media player 3.0.3 Vetinari (revision 3.0.3-1-0-gc2bb759264)
[000056417a4461a0] main libvlc: Esecuzione di vlc con l'interfaccia predefinita. Usa 'cvlc' per utilizzare vlc senza interfaccia.
[000056417a4da540] main playlist: playlist is empty
[00007fcd00000eb0] live555 demux warning: no data received in 10s. Switching to TCP
[00007fcd0000b2d0] main decoder error: buffer deadlock prevented
[000056417a505bf0] pulse audio output warning: starting late (-591 us)
[000056417a505bf0] main audio output warning: playback way too early (-260338): playing silence
[000056417a505bf0] main audio output warning: playback too late (67682): up-sampling
[000056417a505bf0] main audio output warning: playback too early (-60916): down-sampling
[000056417a505bf0] main audio output warning: playback way too early (-191284): playing silence
[000056417a505bf0] main audio output warning: playback way too late (252312): flushing buffers
[000056417a505bf0] pulse audio output warning: starting late (-5953 us)
[000056417a505bf0] main audio output warning: playback way too early (-701316): playing silence
[000056417a505bf0] main audio output warning: playback way too early (-332484): playing silence
[000056417a505bf0] main audio output warning: playback too late (125861): up-sampling
[000056417a505bf0] main audio output warning: playback way too late (297954): flushing buffers
[000056417a505bf0] main audio output warning: playback way too early (-993047): playing silence
[00007fcd0000b2d0] avcodec decoder warning: thread type 1: disabling hardware acceleration
[000056417a505bf0] main audio output warning: playback too late (107083): up-sampling
[000056417a505bf0] main audio output warning: playback way too late (235778): flushing buffers
[00007fcce0001cc0] egl_x11 gl error: cannot select OpenGL API
[000056417a505bf0] main audio output warning: playback way too early (-657714): playing silence
[000056417a505bf0] main audio output warning: playback way too late (238668): flushing buffers
[00007fccf8160b40] main video output warning: picture is too late to be displayed (missing 691 ms)
[00007fccf8160b40] main video output warning: picture is too late to be displayed (missing 491 ms)
[00007fccf8160b40] main video output warning: picture is too late to be displayed (missing 290 ms)
[00007fccf8160b40] main video output warning: picture is too late to be displayed (missing 89 ms)
[000056417a505bf0] main audio output warning: playback way too early (-652182): playing silence
[000056417a505bf0] main audio output warning: playback too late (72927): up-sampling
[000056417a505bf0] main audio output warning: playback too late (98876): up-sampling
[000056417a4da540] main playlist: end of playlist, exiting

关于ffmpeg - ffplay、rtsp 和 tcp 传输协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53806534/

相关文章:

ffmpeg - 如何使用ffmpeg按百分比缩放水印?

node.js - 流畅的 ffmpeg : Adding gif animation as overlay between x time to y time

video - 从视频流中下载加密的 TS 文件

python - 从 moviepy : AttributeError: 'PermissionError' object has no attribute 'message' 导入 VideoFileClip 时出错

ffmpeg youtube 直播不工作

bash - 使用 ffmpeg 创建视频时处理丢失的帧

python-3.x - 如何使用 PIL 或类似的东西用 yuv420 格式数据写入图像

ffmpeg - 我应该在 DEBIAN 上使用什么版本的 FFMPEG 将 RTSP 转码为 RTMP?

ffmpeg - 使用 FFMPEG 选择最接近特定时刻的关键帧

ffmpeg - 使用 ffmpeg 编码原始 nv12 帧