Capturing data stream of a JS / Leaflet animation as MP4

醉酒当歌 提交于 2020-01-24 00:32:11

问题


How can I capture the datastream of a JS / Leaflet animation and download it to MP4?

I am looking for output that looks something like the smooth path traced in these demos: https://github.com/IvanSanchez/Leaflet.Polyline.SnakeAnim

Their author appears to have done them in ffcast or some screencasting softare.

However, I am looking for an automated solution that can be run as script, ideally one that works on the data stream itself (not the screen), perhaps with a headless browser.

I have tried puppeteer-gif and puppeteer-gif-cast but the best frame rate is jumpy.

I have tried WebRTC-Experiment but it requires me to set manual permissions. Ditto the Screen Capture API mentioned here, though this at least seems to work on the data stream itself.


回答1:


The canvas captureStream method combined with the MediaRecorder API should do the trick.

Mind you that Chrome only supports webm as a container format (but does record h264) so you might need a postprocessing step with ffmpeg.



来源:https://stackoverflow.com/questions/59726775/capturing-data-stream-of-a-js-leaflet-animation-as-mp4

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