I was trying to use an Arch solution for streaming to twitch today through FFMPEG, but all of my attempts were in vain because of one simple thing on FFMPEG. it says that the pr
Stream #0: not enough frames to estimate rate; consider increasing probesize
This is just a minor warning. You can ignore it, but if you want it to go away use -probesize
as in input option. You're using it as an output option. Order and placement matters in ffmpeg
.
ffmpeg -probesize 10M -i input ...
0: Input/output error
This is the actual error that is causing failure. It's trying to tell you -i 0
does not refer to any actual input.
So you need to provide an actual input for pulse, such as -i default
.
To list the PulseAudio source devices and their properties run pactl list sources
.
See FFmpeg Devices Documentation: Pulse for more info.
Years ago I tried to make improvements to the sometimes rather poor, outdated, or plain wrong ffmpeg
examples on the Arch Wiki but I got complaints that I violated "Do not make complex edits at once" and rolled it back. Waste of time, so I never touched it again. I recommend the FFmpeg Wiki instead.
Some recommended changes:
#!/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"