02. ์บก์ณ ๋ฐ ๋ นํ
About 4 min
02. ์บก์ณ ๋ฐ ๋ นํ ๊ด๋ จ
์์์ด๋ ์ด๋ฏธ์ง๋ฅผ ์บก์ณํ๊ฑฐ๋ ๋ นํํ๊ธฐ ์ํด ์ฌ์ฉํฉ๋๋ค. ์์์ด๋ ์ด๋ฏธ์ง๋ฅผ ์ฐ์์ ๋๋ ์๊ฐ์ ์ผ๋ก ์บก์ณํ๊ฑฐ๋ ๋ นํํ ์ ์์ต๋๋ค.
FourCC
Four Character Code: ๋์งํธ ๋ฏธ๋์ด ํฌ๋งท ์ฝ๋์ ๋๋ค. ์ฆ, ์ฝ๋ฑ์ ์ธ์ฝ๋ฉ ๋ฐฉ์
CVID, Default, DIB, DIVX, H261, H263, H264, IV32, IV41, IV50, IYUB, MJPG, MP42,
MP43, MPG4, MSVC, PIM1, Prompt, XVI
import datetime
import cv2
capture = cv2.VideoCapture("kara.mp4")
fourcc = cv2.VideoWriter_fourcc(*'XVID')
record = False
while True:
if (capture.get(cv2.CAP_PROP_POS_FRAMES) == capture.get(cv2.CAP_PROP_FRAME_COUNT)):
capture.open("/Image/Star.mp4")
ret, frame = capture.read()
cv2.imshow("VideoFrame", frame)
now = datetime.datetime.now().strftime("%d_%H-%M-%S")
key = cv2.waitKey(33)
if key == 27:
break
elif key == 26:
print("์บก์ณ")
cv2.imwrite("D:/" + str(now) + ".png", frame)
elif key == 24:
print("๋
นํ ์์")
record = True
video = cv2.VideoWriter("D:/" + str(now) + ".avi", fourcc, 20.0, (frame.shape[1], frame.shape[0]))
elif key == 3:
print("๋
นํ ์ค์ง")
record = False
video.release()
if record == True:
print("๋
นํ ์ค..")
video.write(frame)
capture.release()
cv2.destroyAllWindows()
ํค์ฝ๋๊ฐ: 27
= ESC, 26
= Ctrl+Z, 24
= Ctrl+X, 3
= Ctrl+C
ASCII Table
DEC | HEX | OCT | Char |
---|---|---|---|
0 | 00 | 000 | Ctrl+@ NUL |
1 | 01 | 001 | Ctrl+A SOH |
2 | 02 | 002 | Ctrl+B STX |
3 | 03 | 003 | Ctrl+C ETX |
4 | 04 | 004 | Ctrl+D EOT |
5 | 05 | 005 | Ctrl+E ENQ |
6 | 06 | 006 | Ctrl+F ACK |
7 | 07 | 007 | Ctrl+G BEL |
8 | 08 | 010 | Ctrl+H BS |
9 | 09 | 011 | Ctrl+I HT |
10 | 0A | 012 | Ctrl+J LF |
11 | 0B | 013 | Ctrl+K VT |
12 | 0C | 014 | Ctrl+L FF |
13 | 0D | 015 | Ctrl+M CR |
14 | 0E | 016 | Ctrl+N SO |
15 | 0F | 017 | Ctrl+O SI |
16 | 10 | 020 | Ctrl+P DLE |
17 | 11 | 021 | Ctrl+Q DC1 |
18 | 12 | 022 | Ctrl+R DC2 |
19 | 13 | 023 | Ctrl+S DC3 |
20 | 14 | 024 | Ctrl+T DC4 |
21 | 15 | 025 | Ctrl+U NAK |
22 | 16 | 026 | Ctrl+V SYN |
23 | 17 | 027 | Ctrl+W ETB |
24 | 18 | 030 | Ctrl+X CAN |
25 | 19 | 031 | Ctrl+Y EM |
26 | 1A | 032 | Ctrl+Z SUB |
27 | 1B | 033 | Ctrl+[ ESC |
28 | 1C | 034 | Ctrl+\ FS |
29 | 1D | 035 | Ctrl+] GS |
30 | 1E | 036 | Ctrl+^ RS |
31 | 1F | 037 | Ctrl+_ US |
32 | 20 | 040 | Space |
33 | 21 | 041 | ! |
34 | 22 | 042 | " |
35 | 23 | 043 | # |
36 | 24 | 044 | $ |
37 | 25 | 045 | % |
38 | 26 | 046 | & |
39 | 27 | 047 | ' |
40 | 28 | 050 | ( |
41 | 29 | 051 | ) |
42 | 2A | 052 | * |
43 | 2B | 053 | + |
44 | 2C | 054 | , |
45 | 2D | 055 | - |
46 | 2E | 056 | . |
47 | 2F | 057 | / |
48 | 30 | 060 | 0 |
49 | 31 | 061 | 1 |
50 | 32 | 062 | 2 |
51 | 33 | 063 | 3 |
52 | 34 | 064 | 4 |
53 | 35 | 065 | 5 |
54 | 36 | 066 | 6 |
55 | 37 | 067 | 7 |
56 | 38 | 070 | 8 |
57 | 39 | 071 | 9 |
58 | 3A | 072 | : |
59 | 3B | 073 | ; |
60 | 3C | 074 | < |
61 | 3D | 075 | = |
62 | 3E | 076 | > |
63 | 3F | 077 | ? |
64 | 40 | 100 | @ |
65 | 41 | 101 | A |
66 | 42 | 102 | B |
67 | 43 | 103 | C |
68 | 44 | 104 | D |
69 | 45 | 105 | E |
70 | 46 | 106 | F |
71 | 47 | 107 | G |
72 | 48 | 110 | H |
73 | 49 | 111 | I |
74 | 4A | 112 | J |
75 | 4B | 113 | K |
76 | 4C | 114 | L |
77 | 4D | 115 | M |
78 | 4E | 116 | N |
79 | 4F | 117 | O |
80 | 50 | 120 | P |
81 | 51 | 121 | Q |
82 | 52 | 122 | R |
83 | 53 | 123 | S |
84 | 54 | 124 | T |
85 | 55 | 125 | U |
86 | 56 | 126 | V |
87 | 57 | 127 | W |
88 | 58 | 130 | X |
89 | 59 | 131 | Y |
90 | 5A | 132 | Z |
91 | 5B | 133 | [ |
92 | 5C | 134 | \ |
93 | 5D | 135 | ] |
94 | 5E | 136 | ^ |
95 | 5F | 137 | _ |
96 | 60 | 140 | ` |
97 | 61 | 141 | a |
98 | 62 | 142 | b |
99 | 63 | 143 | c |
100 | 64 | 144 | d |
101 | 65 | 145 | e |
102 | 66 | 146 | f |
103 | 67 | 147 | g |
104 | 68 | 150 | h |
105 | 69 | 151 | i |
106 | 6A | 152 | j |
107 | 6B | 153 | k |
108 | 6C | 154 | l |
109 | 6D | 155 | m |
110 | 6E | 156 | n |
111 | 6F | 157 | o |
112 | 70 | 160 | p |
113 | 71 | 161 | q |
114 | 72 | 162 | r |
115 | 73 | 163 | s |
116 | 74 | 164 | t |
117 | 75 | 165 | u |
118 | 76 | 166 | v |
119 | 77 | 167 | w |
120 | 78 | 170 | x |
121 | 79 | 171 | y |
122 | 7A | 172 | z |
123 | 7B | 173 | { |
124 | 7C | 174 | | |
125 | 7D | 175 | } |
126 | 7E | 176 | ~ |
127 | 7F | 177 | DEL |