I'm not having problems with audio/video not in sync. I get audio fine, and in sync. Problem is that the audio file skips. Here's my output: http://youtu.be/D2TdXnXHt8o
Here's my script:
#!/bin/sh
echo "Enter the output file name: "; read name
fullscreen=$(xwininfo -root | grep 'geometry' | awk '{print $2;}')
avconv -f alsa -i pulse -f x11grab -r 30 -s $fullscreen -i :0.0 -vcodec libx264 -acodec mp3 -preset ultrafast -threads 4 -y $name
Using Ubuntu 14.04
It is a shame that avconv has yet to resolve this problem, though is supposed to be an improvement to ffmpeg. On my Ubuntu 14.04 I resorted to installing ffmpeg via
sudo add-apt-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg
then I run ffmpeg
ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 25 -video_size 1920x1080 -i :0.0+0,0 -acodec flac -vcodec libx264 -preset ultrafast -crf 0 -threads 0 screenoutput.mkv
and audio and video are now nicely synced.
I encountered the exact same problem when I tried recording with this similar command (note I am trying to use the lossless screencasting video codec huffyuv instead of trying to encode straight to x264):
avconv -f alsa -i pulse -f x11grab -r 30 -s 1920x1080 -i :0.0 -vcodec huffyuv -acodec libmp3lame -ac 1 -threads auto screencast.avi
After way too much time spent experimenting, I discovered that if I set the verbosity to 'quiet', then the "skipping" or "choppiness" improves somewhat:
avconv -v quiet -f alsa -i pulse -f x11grab -r 24 -s 1920x1080 -i :0.0 -vcodec huffyuv -acodec libmp3lame -ac 1 -threads auto screencast.avi
The only way I found to fully eliminate the problem is to record video and audio separately in two instances of avconv, then kill them to stop recording:
huffyuv:
avconv -v quiet -f x11grab -r 24 -s 1920x1080 -i :0.0 -vcodec huffyuv -threads auto video.mkv & \
avconv -v quiet -f alsa -i pulse -ar 22050 -ab 32 -ac 1 -threads auto audio.mp3 &
x264:
avconv -f x11grab -r 24 -s 1920x1080 -i :0.0 -qscale 0 -vcodec libx264 -crf 26 -preset superfast -v quiet -threads auto -y 001.mkv & \
avconv -f alsa -i pulse -acodec libmp3lame -ar 22050 -ab 32 -ac 1 -threads auto -v quiet -y 001.mp3 &
Both instances of avconv run in the background. To stop recording, kill them both at the same time with:
kill %1 %2
To stitch the audio and the video back together as one file:
avconv -i video.mkv -i audio.mp3 -c:a copy -c:v copy video_and_audio.mkv
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.