Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Getting audio and video to sync with ffmpeg
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
theodis
n00b
n00b


Joined: 19 Mar 2013
Posts: 4

PostPosted: Wed Mar 20, 2013 12:10 am    Post subject: Getting audio and video to sync with ffmpeg Reply with quote

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
View user's profile Send private message
ShadowCat8
Tux's lil' helper
Tux's lil' helper


Joined: 07 Oct 2008
Posts: 137
Location: Arcadia, CA, USA

PostPosted: Wed Mar 20, 2013 12:57 am    Post subject: Reply with quote

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.
_________________
------
"There is no value to explaining sanity to an insane person, just as there is no value of explaining rabies to a rabid dog... They will both bite you for your effort."
-- oldbitman
Back to top
View user's profile Send private message
theodis
n00b
n00b


Joined: 19 Mar 2013
Posts: 4

PostPosted: Wed Mar 20, 2013 2:18 am    Post subject: Reply with quote

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
View user's profile Send private message
syn0ptik
Apprentice
Apprentice


Joined: 09 Jan 2013
Posts: 249

PostPosted: Wed Mar 20, 2013 4:22 am    Post subject: Reply with quote

you also can try add -bufsize 8192 for making buffes for media streams
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum