{"id":3936,"date":"2023-12-05T22:29:32","date_gmt":"2023-12-05T14:29:32","guid":{"rendered":"http:\/\/192.168.31.200\/?p=3936"},"modified":"2023-12-05T22:29:33","modified_gmt":"2023-12-05T14:29:33","slug":"%e5%bd%95%e5%b1%8fpython%e4%bb%a3%e7%a0%81%e6%9d%a5%e8%87%aachatgpt3-5","status":"publish","type":"post","link":"http:\/\/cnliutz.wicp.vip\/?p=3936","title":{"rendered":"\u5f55\u5c4fpython\u4ee3\u7801\u6765\u81eachatgpt3.5"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>import pyautogui\nimport imageio\n\n# Set the duration of the recording in seconds\nduration = 10\n\n# Specify the frames per second (FPS) for the video\nfps = 10\n\n# Specify the output file name\noutput_file = 'screen_recording.mp4'\n\n# Get the screen resolution\nscreen_width, screen_height = pyautogui.size()\n\n# Create a writer object to save the video\nwriter = imageio.get_writer(output_file, fps=fps)\n\ntry:\n    for _ in range(int(fps * duration)):\n        # Capture a screenshot\n        screenshot = pyautogui.screenshot()\n\n        # Convert the screenshot to a NumPy array\n        frame = imageio.core.util.Array(screenshot)\n\n        # Add the frame to the video\n        writer.append_data(frame)\nfinally:\n    # Close the writer to save the video\n    writer.close()\n\nprint(f\"Screen recording saved to {output_file}\")\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-3936","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=\/wp\/v2\/posts\/3936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3936"}],"version-history":[{"count":1,"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=\/wp\/v2\/posts\/3936\/revisions"}],"predecessor-version":[{"id":3937,"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=\/wp\/v2\/posts\/3936\/revisions\/3937"}],"wp:attachment":[{"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3936"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cnliutz.wicp.vip\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}