最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Improve This APNG Webpage Recorder to Capture Smooth 30+ FPS Video - Stack Overflow

programmeradmin1浏览0评论

I have written a Python script using Playwright to record a high-quality APNG video of a webpage. The script captures frames at 100 FPS and saves them as an animated PNG. I use it to record bar chart race animations from Flourish Studio, such as this one:
/visualisation/21660262/

Here is my script:

from playwright.sync_api import sync_playwright
import keyboard
import time
import os
import threading
from PIL import Image
import io

# Output folder
output_folder = r"E:\Desktop\New folder (4)\New folder (3)"
os.makedirs(output_folder, exist_ok=True)  # Ensure directory exists

capturing = False  # Flag to control capturing state
saving = False  # Prevent capturing while saving
screenshot_buffer = []  # Store screenshots in memory (RAM)
lock = threading.Lock()  # Prevent race conditions

# Function to listen for keyboard inputs
def listen_keys():
    """ Listens for keyboard input to start/stop capturing or exit script. """
    global capturing, saving
    while True:
        if keyboard.is_pressed("F3"):  # Start capturing
            if not capturing and not saving:
                print("
发布评论

评论列表(0)

  1. 暂无评论