5

When streaming my desktop to twitch.tv using avconv audio and video are out of sync. Sometimes it is already out of sync when starting the stream and sometimes they just drift apart after a while. This is the script I use for streaming:

#!/bin/bash
INRES="1920x1080" # input resolution
OUTRES="1280x720"
OFFSET="0,0"
FPS="30" # target FPS
MAXRATE="3000k"
BUFSIZE="3000k"
AUDIOBITRATE="192k"
QUAL="medium" # one of the many FFMPEG preset
STREAM_KEY=$(cat ~/.twitch_key)
URL="rtmp://live.twitch.tv/app/$STREAM_KEY"
SHOW_REGION="0"

avconv -v quiet -f x11grab -show_region $SHOW_REGION -s "$INRES" -r "$FPS" -i :0.0+$OFFSET \
-f alsa -ac 2 -b:a "$AUDIOBITRATE" -i pulse -c:v libx264 -crf 30 -preset "$QUAL" \
-s "$OUTRES" -vol 11200 -c:a libmp3lame -ar 44100 -pix_fmt yuv420p -maxrate "$MAXRATE" -bufsize "$BUFSIZE" \
-f flv "$URL"

exit $?
3

1 Answer 1

3

When ssr outputs:

Warning: Audio input is more than 5% too fast, video and audio will be out of sync.

or

Warning: Audio input is more than 5% too slow, video and audio will be out of sync.

Do this:

Edit /etc/pulse/daemon.conf, make sure it contains these lines (adding or uncommenting):

default-sample-rate = 44100
alternate-sample-rate = 44100

There is an upstream bug which is marked as fixed but the patch is not in the repository of Ubuntu. The simplescreenrecorder bug which contains this workaround.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.