Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 $?
share|improve this question
    
Try with the -async option: askubuntu.com/questions/227497/… –  Takkat Aug 24 '13 at 19:24
    
@Takkat This option makes the sound stutter completely. –  c_korn Aug 24 '13 at 23:25
    
This piece of software looks fine: maartenbaert.be/simplescreenrecorder This commit also seems to address the issue I described here: github.com/MaartenBaert/ssr/commit/… –  c_korn Aug 28 '13 at 20:05

1 Answer 1

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.

Try 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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