Score:2

Screencast monitor and speakers using ffmpeg: audio delay problem

ma flag

Question? The task is to record simultaneously everything that we see on the monitor and hear from the speakers.

I wrote the following script:

Set the variable:

speaker=alsa_output.pci-[my speakers].analog-stereo.monitor

We write:

ffmpeg -use_wallclock_as_timestamps 1 -f pulse \
-i $speaker -f x11grab -s 1200x900 -r 15 -i :0.0 \
-vcodec qtrle screencast2.mov

The problem is that the sound is recorded with a delay, and of course I need it synchronously. What is the reason? What to fix?

I plowed the entire I> and could not find the answer.

mchid avatar
bo flag
Does it have to be for `mov`? Have you tried [using different encoders](https://superuser.com/a/1423215/317065)?
mchid avatar
bo flag
Also, I tried this and I get no audio delay. I am using a USB out for audio so that might make a difference however, it makes it difficult for me to test a solution. However, I did not record for very long. Does the audio start to delay after a certain period of time after you start recording?
mchid avatar
bo flag
Also, when you say there is a delay, do you mean to say that the audio is not in sync with the video (when people move their lips the words do not match) or do you mean to say that the audio does not start recording and there is no audio for the first few seconds of the video (but the words do match when the lips move)?
Grannik avatar
ma flag
when people move their lips the words do not match
mchid avatar
bo flag
Does it help to use different encoders like this? `ffmpeg -use_wallclock_as_timestamps 1 -f pulse -i $speaker -f x11grab -s 1200x900 -r 15 -i :0.0 -acodec aac -vcodec mpeg4 -preset medium -qscale:v 0 rec.mkv`
mchid avatar
bo flag
There's also [this similar answer](https://askubuntu.com/a/154275/167115), however, it is outdated and I **do not recommend using the ppa**. Simply use the ffmpeg command referenced in the question and/or substitute the `-vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le file.mkv` part at the end of your command.
mchid avatar
bo flag
Also, if video quality isn't good, it helps to use `-qscale:v 0`
Grannik avatar
ma flag
mkv? Need to try.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.