如何使用Puppeteer拍摄包含视频的页面的屏幕截图 [英] How to use Puppeteer to take Screenshots of Pages that Contain Video

查看:402
本文介绍了如何使用Puppeteer拍摄包含视频的页面的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Puppeteer打开网站并拍摄视频的屏幕截图。但是,运行puppeteer的默认Chromium浏览器不适用于视频类型。

I'm currently using Puppeteer to open a site and take a screenshot of a video. However, the default Chromium browser that puppeteer runs doesn't work with video types.

我使用Puppeteer的本地版本Chrome启动,一切正常。

I launched with a local version of Chrome with Puppeteer and everything is working.

有没有一种方法可以使用puppeteer打开实际的chrome浏览器实例,而不必指定指向.exe的本地链接,以使其在托管时更具可扩展性,并且减少了对目录的依赖?

Is there a way to open an actual chrome browser instance with puppeteer without having to specify a local link to the .exe to make it more scalable and less reliant on a directory when being hosted?

Puppeteer 2.0.0

Puppeteer 2.0.0

注意:我正在运行非Puppeteer的-chromium实例(没有指向Chrome.exe的目录)

Note: I'm running a non-chromium instance with Puppeteer (without a directory to Chrome.exe)

推荐答案

在以下情况下,您可能会发现Puppeteer的行为不符合预期控制包含音频和视频的页面。 (例如,视频播放/屏幕截图可能会失败。)有两个原因为此:

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).

来源: 常见问题:puppeteer不支持哪些功能?

这篇关于如何使用Puppeteer拍摄包含视频的页面的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆