ffmpeg:考虑增加 probesize 错误,但永远不会满足
ffmpeg: consider increasing probesize error, but it is never satisfied
我今天尝试使用 Arch solution 通过 FFMPEG 流式传输抽搐,但由于 FFMPEG 上的一件简单事情,我所有的尝试都是徒劳的。它说probesize不够大,所以我本能地增加了probesize值越来越多......现在已经-probesize "500M"
了,但它仍然说它还不够。这是代码片段
[x11grab @ 0x5631f846cd00] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0':
Duration: N/A, start: 1603397505.341400, bitrate: 1007124 kb/s
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1366x768, 1007124 kb/s, 30 fps, 1000k tbr, 1000k tbn, 1000k tbc
0: Input/output error
和代码
#!/bin/bash
INRES="1366x768" # input resolution
OUTRES="1366x768" # output resolution
FPS="30" # target FPS
GOP="60" # i-frame interval, should be double of FPS,
GOPMIN="30" # min i-frame interval, should be equal to fps,
THREADS="2" # max 6
CBR="1000k" # constant bitrate (should be between 1000k - 3000k)
QUALITY="ultrafast" # one of the many FFMPEG preset
AUDIO_RATE="44100"
PROBESZ="500M" # specify a size for the ffmpeg tool to assess frames
STREAM_KEY="" # paste the stream key after calling stream_now
SERVER="live-mia" # twitch server in miami Florida, see https://stream.twitch.tv/ingests/ for list
ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :0.0 -f pulse -i 0 -f flv -ac 2 -ar $AUDIO_RATE \
-vcodec libx264 -g $GOP -keyint_min $GOPMIN -b:v $CBR -minrate $CBR -maxrate $CBR -pix_fmt yuv420p\
-s $OUTRES -preset $QUALITY -tune film -acodec aac -threads $THREADS -strict normal \
-bufsize $CBR -probesize $PROBESZ "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"
尽管它是存储在.bashrc 中的解决方案,但我将其存储在脚本中以手动调用。
如果这有帮助,这里是 ffmpeg 在错误之前显示的精美横幅
ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Stream #0: not enough frames to estimate rate; consider increasing probesize
这只是一个小警告。您可以忽略它,但如果您希望它消失,请像在输入选项中那样使用 -probesize
。您将其用作输出选项。 Order and placement 在 ffmpeg
中很重要。
ffmpeg -probesize 10M -i input ...
0: Input/output error
这是导致失败的实际错误。它试图告诉你 -i 0
没有引用任何实际输入。
因此您需要为脉冲提供实际输入,例如-i default
。
列出 PulseAudio 源设备及其属性 运行 pactl list sources
.
有关详细信息,请参阅 FFmpeg Devices Documentation: Pulse。
剧本
几年前,我试图对 Arch Wiki 上有时相当糟糕、过时或完全错误的 ffmpeg
示例进行改进,但有人抱怨我违反了“不要一次进行复杂的编辑”和把它滚回去。浪费时间,所以我再也没有碰过它。我建议改用 FFmpeg Wiki。
一些建议的更改:
#!/bin/bash
INRES="1366x768" # input resolution
OUTRES="1366x768" # output resolution
FPS="30" # target FPS. Use 30 or 60. 60 is preferred for games if your computer can handle it.
GOP="60" # i-frame interval, should be double of $FPS
BITRATE="4000k" # bitrate (should be between 3000k - 6000k). See https://stream.twitch.tv/encoding/
BUFSIZE="8000k" # 2x to 4x $BITRATE
PRESET="fast" # use slowest preset that still maintains $FPS. See https://trac.ffmpeg.org/wiki/Encode/H.264#Preset
AUDIO_SAMPLE_RATE="44100"
STREAM_KEY="" # paste the stream key after calling stream_now
SERVER="live-mia" # twitch server in miami Florida, see https://stream.twitch.tv/ingests/ for list
ffmpeg \
-f x11grab -video_size "$INRES" -framerate "$FPS" -i :0.0 \
-f pulse -channels 2 -sample_rate "$AUDIO_SAMPLE_RATE" -i default \
-c:v libx264 -g "$GOP" -b:v "$BITRATE" -maxrate "$BITRATE" -bufsize "$BUFSIZE" -vf format=yuv420p \
-s "$OUTRES" -preset "$PRESET" -c:a aac \
-f flv "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"
我今天尝试使用 Arch solution 通过 FFMPEG 流式传输抽搐,但由于 FFMPEG 上的一件简单事情,我所有的尝试都是徒劳的。它说probesize不够大,所以我本能地增加了probesize值越来越多......现在已经-probesize "500M"
了,但它仍然说它还不够。这是代码片段
[x11grab @ 0x5631f846cd00] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0':
Duration: N/A, start: 1603397505.341400, bitrate: 1007124 kb/s
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1366x768, 1007124 kb/s, 30 fps, 1000k tbr, 1000k tbn, 1000k tbc
0: Input/output error
和代码
#!/bin/bash
INRES="1366x768" # input resolution
OUTRES="1366x768" # output resolution
FPS="30" # target FPS
GOP="60" # i-frame interval, should be double of FPS,
GOPMIN="30" # min i-frame interval, should be equal to fps,
THREADS="2" # max 6
CBR="1000k" # constant bitrate (should be between 1000k - 3000k)
QUALITY="ultrafast" # one of the many FFMPEG preset
AUDIO_RATE="44100"
PROBESZ="500M" # specify a size for the ffmpeg tool to assess frames
STREAM_KEY="" # paste the stream key after calling stream_now
SERVER="live-mia" # twitch server in miami Florida, see https://stream.twitch.tv/ingests/ for list
ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :0.0 -f pulse -i 0 -f flv -ac 2 -ar $AUDIO_RATE \
-vcodec libx264 -g $GOP -keyint_min $GOPMIN -b:v $CBR -minrate $CBR -maxrate $CBR -pix_fmt yuv420p\
-s $OUTRES -preset $QUALITY -tune film -acodec aac -threads $THREADS -strict normal \
-bufsize $CBR -probesize $PROBESZ "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"
尽管它是存储在.bashrc 中的解决方案,但我将其存储在脚本中以手动调用。
如果这有帮助,这里是 ffmpeg 在错误之前显示的精美横幅
ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Stream #0: not enough frames to estimate rate; consider increasing probesize
这只是一个小警告。您可以忽略它,但如果您希望它消失,请像在输入选项中那样使用 -probesize
。您将其用作输出选项。 Order and placement 在 ffmpeg
中很重要。
ffmpeg -probesize 10M -i input ...
0: Input/output error
这是导致失败的实际错误。它试图告诉你 -i 0
没有引用任何实际输入。
因此您需要为脉冲提供实际输入,例如-i default
。
列出 PulseAudio 源设备及其属性 运行 pactl list sources
.
有关详细信息,请参阅 FFmpeg Devices Documentation: Pulse。
剧本
几年前,我试图对 Arch Wiki 上有时相当糟糕、过时或完全错误的 ffmpeg
示例进行改进,但有人抱怨我违反了“不要一次进行复杂的编辑”和把它滚回去。浪费时间,所以我再也没有碰过它。我建议改用 FFmpeg Wiki。
一些建议的更改:
#!/bin/bash
INRES="1366x768" # input resolution
OUTRES="1366x768" # output resolution
FPS="30" # target FPS. Use 30 or 60. 60 is preferred for games if your computer can handle it.
GOP="60" # i-frame interval, should be double of $FPS
BITRATE="4000k" # bitrate (should be between 3000k - 6000k). See https://stream.twitch.tv/encoding/
BUFSIZE="8000k" # 2x to 4x $BITRATE
PRESET="fast" # use slowest preset that still maintains $FPS. See https://trac.ffmpeg.org/wiki/Encode/H.264#Preset
AUDIO_SAMPLE_RATE="44100"
STREAM_KEY="" # paste the stream key after calling stream_now
SERVER="live-mia" # twitch server in miami Florida, see https://stream.twitch.tv/ingests/ for list
ffmpeg \
-f x11grab -video_size "$INRES" -framerate "$FPS" -i :0.0 \
-f pulse -channels 2 -sample_rate "$AUDIO_SAMPLE_RATE" -i default \
-c:v libx264 -g "$GOP" -b:v "$BITRATE" -maxrate "$BITRATE" -bufsize "$BUFSIZE" -vf format=yuv420p \
-s "$OUTRES" -preset "$PRESET" -c:a aac \
-f flv "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"