解决了ffmpeg:考虑增加探针大小错误,但从未满足 Stream #0: not enough frames to estimate rate; consider increasing probesize 0: Input/output error 脚本

问题描述

我当时尝试使用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="$1" # 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 placementffmpeg中很重要。

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="$1" # 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"

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...