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

I have written a Python script using Playwright to record a high-quality APNG video of a webpage. The s

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("

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744718711a4589779.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信