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