将 'timeout' 标志添加到 ffprobe/ffmpeg 会导致它立即失败
Adding 'timeout' flag to ffprobe/ffmpeg causes it to fail immediately
如果我 运行 ffprobe -timeout 20 -v trace -print_format json -show_format -show_streams 'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_2mb.mp4'
,即使我将超时设置为 20 秒,命令也会立即失败并出现 Connection timed out
错误。它不会等待将近 20 秒,而是立即退出,退出代码为 1。这是跟踪输出。
ffprobe version 3.2.2 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160830
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
{
[http @ 0x5598e7df1e20] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[http @ 0x5598e7df1e20] request: GET /video/mp4/720/big_buck_bunny_720p_2mb.mp4 HTTP/1.1
User-Agent: Lavf/57.56.100
Accept: */*
Range: bytes=0-
Connection: close
Host: www.sample-videos.com
Icy-MetaData: 1
http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_2mb.mp4: Connection timed out
}
如果我删除 -timeout 20
标志,该命令可以正常工作。如何让 ffprobe
使用超时?
每个协议-timeout
的单位不同
在 HTTP 中,单位是微秒。
我已经通过添加选项解决了 rtsp 流媒体的问题
-stimeout 8000 // in microseconds
有关详细信息,请参阅文档http://ffmpeg.org/ffmpeg-protocols.html#rtsp
如果我 运行 ffprobe -timeout 20 -v trace -print_format json -show_format -show_streams 'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_2mb.mp4'
,即使我将超时设置为 20 秒,命令也会立即失败并出现 Connection timed out
错误。它不会等待将近 20 秒,而是立即退出,退出代码为 1。这是跟踪输出。
ffprobe version 3.2.2 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160830
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
{
[http @ 0x5598e7df1e20] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[http @ 0x5598e7df1e20] request: GET /video/mp4/720/big_buck_bunny_720p_2mb.mp4 HTTP/1.1
User-Agent: Lavf/57.56.100
Accept: */*
Range: bytes=0-
Connection: close
Host: www.sample-videos.com
Icy-MetaData: 1
http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_2mb.mp4: Connection timed out
}
如果我删除 -timeout 20
标志,该命令可以正常工作。如何让 ffprobe
使用超时?
每个协议-timeout
的单位不同
在 HTTP 中,单位是微秒。
我已经通过添加选项解决了 rtsp 流媒体的问题
-stimeout 8000 // in microseconds
有关详细信息,请参阅文档http://ffmpeg.org/ffmpeg-protocols.html#rtsp