Play mp4 in chromium with puppeteer, windows

帅比萌擦擦* 提交于 2020-06-26 06:41:53

问题


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?


回答1:


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',
});


来源:https://stackoverflow.com/questions/47976790/play-mp4-in-chromium-with-puppeteer-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!