PYTHONPORTAL Telegram 4537
Экранный рекордер с помощью Python

screen_size = pyautogui.size()
fps = 20
fourcc = cv2.VideoWriter_fourcc(*"XVID")
output_file = "screen_recording_clcoding.mp4"
out = cv2.VideoWriter(output_file, fourcc, fps, (screen_size.width, screen_size.height))


🔸screen_size = pyautogui.size() — получаем разрешение экрана (ширину и высоту).
🔸fps = 20 — задаём частоту кадров (20 кадров в секунду).
🔸fourcc — кодек видео (XVID).
🔸output_file — имя файла для сохранения.
🔸cv2.VideoWriter(...) — создаёт объект, который будет записывать кадры в видеофайл.

Старт записи

print("Recording... Press 'q' to stop.")


Сообщение пользователю, что началась запись и как её остановить.

Главный цикл записи

while True:
screen = pyautogui.screenshot()
frame = np.array(screen)
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
out.write(frame)


Что происходит:

🔸pyautogui.screenshot() — делает скриншот всего экрана.
🔸np.array(screen) — переводим скриншот в массив пикселей.
🔸cv2.cvtColor(..., cv2.COLOR_RGB2BGR) — OpenCV использует BGR-порядок, а pyautogui возвращает RGB, нужно преобразовать.
🔸out.write(frame) — сохраняем кадр в видеофайл.

Остановка по нажатию клавиши 'q'

if keyboard.is_pressed('q'):
print("Recording stopped.")
break


Как только пользователь нажимает клавишу 'q', цикл прерывается.

Сохраняем и закрываем файл

out.release()
print(f"Video saved to {output_file}")


🔸out.release() — освобождаем ресурсы и сохраняем файл.

👉 @PythonPortal
Please open Telegram to view this post
VIEW IN TELEGRAM



tgoop.com/PythonPortal/4537
Create:
Last Update:

Экранный рекордер с помощью Python

screen_size = pyautogui.size()
fps = 20
fourcc = cv2.VideoWriter_fourcc(*"XVID")
output_file = "screen_recording_clcoding.mp4"
out = cv2.VideoWriter(output_file, fourcc, fps, (screen_size.width, screen_size.height))


🔸screen_size = pyautogui.size() — получаем разрешение экрана (ширину и высоту).
🔸fps = 20 — задаём частоту кадров (20 кадров в секунду).
🔸fourcc — кодек видео (XVID).
🔸output_file — имя файла для сохранения.
🔸cv2.VideoWriter(...) — создаёт объект, который будет записывать кадры в видеофайл.

Старт записи

print("Recording... Press 'q' to stop.")


Сообщение пользователю, что началась запись и как её остановить.

Главный цикл записи

while True:
screen = pyautogui.screenshot()
frame = np.array(screen)
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
out.write(frame)


Что происходит:

🔸pyautogui.screenshot() — делает скриншот всего экрана.
🔸np.array(screen) — переводим скриншот в массив пикселей.
🔸cv2.cvtColor(..., cv2.COLOR_RGB2BGR) — OpenCV использует BGR-порядок, а pyautogui возвращает RGB, нужно преобразовать.
🔸out.write(frame) — сохраняем кадр в видеофайл.

Остановка по нажатию клавиши 'q'

if keyboard.is_pressed('q'):
print("Recording stopped.")
break


Как только пользователь нажимает клавишу 'q', цикл прерывается.

Сохраняем и закрываем файл

out.release()
print(f"Video saved to {output_file}")


🔸out.release() — освобождаем ресурсы и сохраняем файл.

👉 @PythonPortal

BY Python Portal




Share with your friend now:
tgoop.com/PythonPortal/4537

View MORE
Open in Telegram


Telegram News

Date: |

Find your optimal posting schedule and stick to it. The peak posting times include 8 am, 6 pm, and 8 pm on social media. Try to publish serious stuff in the morning and leave less demanding content later in the day. The creator of the channel becomes its administrator by default. If you need help managing your channel, you can add more administrators from your subscriber base. You can provide each admin with limited or full rights to manage the channel. For example, you can allow an administrator to publish and edit content while withholding the right to add new subscribers. Don’t publish new content at nighttime. Since not all users disable notifications for the night, you risk inadvertently disturbing them. Just at this time, Bitcoin and the broader crypto market have dropped to new 2022 lows. The Bitcoin price has tanked 10 percent dropping to $20,000. On the other hand, the altcoin space is witnessing even more brutal correction. Bitcoin has dropped nearly 60 percent year-to-date and more than 70 percent since its all-time high in November 2021. Matt Hussey, editorial director of NEAR Protocol (and former editor-in-chief of Decrypt) responded to the news of the Telegram group with “#meIRL.”
from us


Telegram Python Portal
FROM American