View previous topic :: View next topic |
Author |
Message |
theodis n00b
Joined: 19 Mar 2013 Posts: 4
|
Posted: Wed Mar 20, 2013 12:10 am Post subject: Getting audio and video to sync with ffmpeg |
|
|
I'm trying to stream video and audio to twitch.tv using ffmpeg however I'm unable to get the video and audio to sync properly. Audio lags roughly 7 seconds behind the video and I'm having no luck fiddling with the arguments to get it to work. Here's the script I've set up for starting up ffmpeg
Code: | #!/bin/bash
API_KEY="`cat .twitch_key`"
FPS="20"
THREADS=5
INRES=`~/getres.sh`
OUTRES='720x400'
ffmpeg \
-f x11grab -s "$INRES" -r $FPS -i :1 \
-f pulse -i default \
-vcodec libx264 -pix_fmt yuv420p -s "$OUTRES" \
-acodec libmp3lame -ab 64k -ar 22050 -threads $THREADS \
-f flv "rtmp://live.twitch.tv/app/$API_KEY" |
|
|
Back to top |
|
|
ShadowCat8 Apprentice
Joined: 07 Oct 2008 Posts: 173 Location: San Bernardino, CA, USA
|
Posted: Wed Mar 20, 2013 12:57 am Post subject: |
|
|
If I understand this correctly, you are trying to send live streams of video and audio of your desktop over the network to twitch.tv?
In my experience, if you try to send them both as separate live streams, you will always have sync issues at the other end. Your best bet would be to create a static file locally to send up to the server. You can't necessarily account for network lag, and it *will* play a part in live streams.
HTH. Let us know. _________________ ________________________
"As far as the laws of mathematics refer to reality, they are not
certain, and as far as they are certain, they do not refer to reality."
-- Albert Einstein |
|
Back to top |
|
|
theodis n00b
Joined: 19 Mar 2013 Posts: 4
|
Posted: Wed Mar 20, 2013 2:18 am Post subject: |
|
|
Well I changed the script to just dump the output to a local file(on a tmpfs so write speed shouldn't be an issue), but the audio and video are still out of sync so I definitely have a problem before it even gets to transmitting the data on the network. |
|
Back to top |
|
|
syn0ptik Apprentice
Joined: 09 Jan 2013 Posts: 267
|
Posted: Wed Mar 20, 2013 4:22 am Post subject: |
|
|
you also can try add -bufsize 8192 for making buffes for media streams |
|
Back to top |
|
|
|