Xvfb and pulse audio not sync

156 views Asked by At

I'm excited to introduce my new JavaScript server-side library called XFP Streamer, designed to handle recording and streaming Puppeteer window content. However, I'm currently facing an issue with audio synchronization, and I could really use some help from someone experienced with ffmpeg and recording in general.

The library's repository is available on GitHub, and I warmly welcome any contributions or assistance. Feel free to check it out at https://github.com/mboussaid/xfp-streamer.

Below is a simple example demonstrating how to record the Google website into a file.flv video file using XFP:

const XFP = require('./index');
XFP.onReady().then(async ()=>{
    // create new xfp instance
    const xfp = new XFP({
        debug:1
    });
    await xfp.onStart();
    // record everyting inside the file file.flv
    xfp.pipeToFile('file.flv',{
        debug:1
    })
    // xfp.pipeToRtmp('file.flv','RTMP LINK HERE')
    await xfp.onUseUrl('https://www.google.com') // navigate to google
    setTimeout(async ()=>{
        await xfp.onStop();
    },5000) // stop everyting after 5 seconds
},(missing)=>{
    // missing tools
    console.log('Missing tools',missing)
})

Please note that to ensure proper functionality, you will need to have the following tools installed:

pulseaudio xvfb ffmpeg pactl pacmd Currently, I'm facing an issue with audio and video synchronization not working as expected. If you have experience with ffmpeg and recording, I would greatly appreciate your help in resolving this issue.

Thank you all for your support, and I look forward to your contributions!

Best regards,

1

There are 1 answers

1
GStarP On

In order to share some insights and a very partial solution:

We are using ffmpeg to record a electron window in linux server without GUI. The video are recorded from Xvfb and the audio are recorded from pulseaudio. The electron window will load a video conferencing web app.

Our experiments show that, the audio always be 1~2 seconds faster than video. However, when you start recording after video and audio are all played already, they are sync! Besides this situation, no matter video plays first or audio plays first, the audio is always faster.