-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathants_v1.2.py
54 lines (46 loc) · 1.53 KB
/
ants_v1.2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import cv2
import numpy as np
from tqdm import tqdm
# Define the available resolutions
resolutions = [
(320, 240),
(640, 480),
(1280, 720),
(1920, 1080),
(750, 1334), # iPhone 6/7/8
(1080, 1920), # iPhone 6/7/8 Plus
(1125, 2436), # iPhone X/XS/11 Pro
(1242, 2688), # iPhone XS Max/11 Pro Max
(1440, 2560), # Google Pixel 2 XL
(1440, 3040), # Samsung Galaxy S10/S20
(1440, 3200), # Sony Xperia 1 II
(1600, 2560), # Google Pixel 4 XL
(2160, 3840) # Samsung Galaxy S21 Ultra
]
# Print the available resolutions
print("Available resolutions:")
for i, res in enumerate(resolutions):
if i == 4:
print("\nFor smartphones:")
print(f"{i+1}. {res[0]}x{res[1]}")
print()
# Ask the user to select or enter a resolution
res_choice = input("Enter the number of your choice or enter a custom resolution (e.g. 1920x1080): ")
if "x" in res_choice:
resolution = tuple(map(int, res_choice.split("x")))
else:
res_choice = int(res_choice)
resolution = resolutions[res_choice-1]
# Define the video codec and frame rate
codec = cv2.VideoWriter_fourcc(*"mp4v")
fps = 60
# Create the video writer object
filename = f"static_{resolution[0]}x{resolution[1]}.mp4"
out = cv2.VideoWriter(filename, codec, fps, resolution)
# Generate and write each frame of the video
for i in tqdm(range(fps * 10)):
frame = np.random.randint(0, 255, (resolution[1], resolution[0], 3), dtype=np.uint8)
out.write(frame)
# Release the video writer object
out.release()
print(f"Static video saved to {filename}")