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 $?
-async
option: askubuntu.com/questions/227497/…