Body: <p>This is on linux with pulseaudio. I need to record a video with a rather bare-bones recorder that runs in chrome. I decided to fake a camera and a mic so that I can edit the video then use ffmpeg to send the video to a dummy camera created with v4l2loopback and set the chrome input in pavucontrol. This s what I have:</p>
  
  <pre><code>ffmpeg -re -i ~/xxx.mp4 -map 0:v -f v4l2 /dev/video2 -f pulse "alsa_output.pci-0000_00_1f.3.analog-stereo.monitor"
  </code></pre>
  
  <p>where /dev/video2 is the loopback camera. This seems to work fine, but the audio lags the video by a few seconds. I verified that they are very much in sync by playing the mp4 normally. How do I fix this?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-06T18:15:24.630Z
Comments.Text: Is it a consistent lag or does it change over time?
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-06T21:43:23.457Z
Comments.Text: The lag seems to be roughly the same after 22 minutes of streaming.
Comments.UserDisplayName: melisgl
Tags: <ffmpeg><linux>
Title: ffmpeg fake camera and mic out of sync
UserDisplayName: melisgl
ThreadText: # ffmpeg fake camera and mic out of sync
  
  (Asked by: username_0 on 2020-04-06)
  
  This is on linux with pulseaudio. I need to record a video with a rather bare-bones recorder that runs in chrome. I decided to fake a camera and a mic so that I can edit the video then use ffmpeg to send the video to a dummy camera created with v4l2loopback and set the chrome input in pavucontrol. This s what I have:
  
  ```
  ffmpeg -re -i ~/xxx.mp4 -map 0:v -f v4l2 /dev/video2 -f pulse "alsa_output.pci-0000_00_1f.3.analog-stereo.monitor"
  
  ```
  
  where /dev/video2 is the loopback camera. This seems to work fine, but the audio lags the video by a few seconds. I verified that they are very much in sync by playing the mp4 normally. How do I fix this?
  
  **Tags:** ffmpeg, linux
  
  > **Comments:**
  > **username_1**: Is it a consistent lag or does it change over time?  
  > **username_0**: The lag seems to be roughly the same after 22 minutes of streaming.  
  
  ---
  
  ## 0 answers
  
  