My problem
I can't get ffmpeg or xvfb-run to stream the full screen to ffplay/videolan, it only captures a part of the screen.
Update 2
I answered the question myself in a follow up answer, hopefully it can be useful for someone else with the same problem.
Update 1
So the problem is definitely with xvfb-run, since the two following commands, still give a webm file, that only show parts of the screen
ffmpeg -f x11grab -i :99 -g 50 -b:v 4000k -maxrate 4000k -bufsize 8000k -f webm -s 384x216 "blank.webm"
xvfb-run -n 99 -a --server-args="-screen 0 1024x8000x24 -ac -nolisten tcp -dpi 96 +extension RANDR" "node index.js"
What I've tried
- I've tried changing ffmpeg command and xvfb-run, for example adding "-vf format=yuv420p" or "-filter:v "crop=iw-400:ih-40,scale=960:720" to ffmpeg command
- I've tried to show other applications under xvfb-run instead of puppeteer (chrome..)
- Recording screen with ffmpeg and saving it to a file, to see if there's a problem with the rtmp stream
But still no luck. That's why I'm reaching out to the stackoverflow community.
xvfb-run command
xvfb-run -n 99 -a --server-args="-screen 0 1024x8000x24 -ac -nolisten tcp -dpi 96 +extension RANDR" "node index.js"
ffmpeg command to capture xvfb-run virtual screen
ffmpeg -f x11grab -i :99 -f pulse -i default -c:v libx264 -c:a aac -g 50 -b:v 4000k -maxrate 4000k -bufsize 8000k -f flv -listen 1 rtmp://localhost:4444/stream
And finally to show the rtmp stream
ffplay -fflags -nobuffer -flags low_delay -probesize 32 -flags low_delay -analyzeduration 0 -i rtmp://localhost:4444/stream
The puppeteer script (index.js) which xfvb-runs
import puppeteer from 'puppeteer';
let initPuppeteer = async () => {
const launchArgs = [
//'--window-size=1280,1024',
'--disable-web-security',
'--disable-features=IsolateOrigins',
'--disable-site-isolation-trials',
'--app',
'--kiosk',
]
await puppeteer.launch({headless: false, ignoreDefaultArgs: ["--enable-automation"], args: launchArgs});
const page = await this.browser.newPage();
const device = puppeteer.devices['Nexus 10'];
await page.emulate(device);
await page.goto("https://google.com");
}
initPuppeteer()