简体   繁体   中英

Play mp4 in chromium with puppeteer, windows

I'm developing with puppeteer in node on windows 10. The problem is that when I open a site playing an mp4 file the browser says me that it is not supported.

I found this package: chromium-codecs-ffmpeg-nonfree ; but it is for linux!

How can I play .mp4 in Chromium with puppeteer on windows?

The Puppeteer Documentation has an answer for this:

Q: What features does Puppeteer not support?

You may find that Puppeteer does not behave as expected when controlling pages that incorporate audio and video. (For example, video playback/screenshots is likely to fail .) There are two reasons for this:

  • Puppeteer is bundled with Chromium--not Chrome--and so by default, it inherits all of Chromium's media-related limitations . This means that Puppeteer does not support licensed formats such as AAC or H.264. (However, it is possible to force Puppeteer to use a separately-installed version Chrome instead of Chromium via the executablePath option to puppeteer.launch . You should only use this configuration if you need an official release of Chrome that supports these media formats.)
  • Since Puppeteer (in all configurations) controls a desktop version of Chromium/Chrome, features that are only supported by the mobile version of Chrome are not supported. This means that Puppeteer does not support HTTP Live Streaming (HLS) .

Therefore, in order to screenshot video playback in Puppeteer, you will need to set the executablePath as a separately installed Chrome executable:

const browser = await puppeteer.launch({
  executablePath: '/path/to/Chrome',
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM