如何使用Puppeteer拍摄包含视频的页面的屏幕截图

如何使用Puppeteer拍摄包含视频的页面的屏幕截图

本文介绍了如何使用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与Chromium捆绑在一起,而不是Chrome,因此默认情况下,
    继承了所有。
    表示Puppeteer不支持AAC或
    H.264之类的许可格式。 (但是,可以通过
    。如果您需要
    支持这些媒体格式的正式Chrome浏览器,则只应
    使用此配置。)

  • 自从Puppeteer(总而言之)配置)可控制桌面版
    Chromium / Chrome,不支持仅移动版
    Chrome支持的功能。这意味着Puppeteer

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

来源:

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

08-11 09:24