-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeff_Engine.py
More file actions
58 lines (48 loc) · 1.27 KB
/
Copy pathDeff_Engine.py
File metadata and controls
58 lines (48 loc) · 1.27 KB
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
55
56
57
58
# import the necessary packages
from deffcode import FFdecoder
import cv2
ffparams = {
"-vcodec": None,
"-enforce_cv_patch": True,
"-ffprefixes": [
"-vsync",
"0",
"-hwaccel",
"cuda",
"-hwaccel_output_format",
"cuda",
],
"-custom_resolution": "null",
"-framerate": "null",
"-vf": "scale_cuda=640:360,"
+ "fps=60.0,"
+ "hwdownload,"
+ "format=nv12",
}
# initialize and formulate the decoder
decoder = FFdecoder(
f"C:\workspace\github\wxPython_WallpaperEngine\src\H265.mp4",
custom_ffmpeg=r"C:\workspace\github\wxPython_WallpaperEngine\ffmpeg7.1\bin",
frame_format="null",
verbose=True,
**ffparams,
).formulate()
# grab RGB24(default) frame from decoder
for frame in decoder.generateFrame():
# check if frame is None
if frame is None:
break
# {do something with the frame here}
frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_NV12)
# lets print its shape
#print(frame.shape) # for e.g. (1080, 1920, 3)
# Show output window
cv2.imshow("Output", frame)
# check for 'q' key if pressed
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
# close output window
cv2.destroyAllWindows()
# terminate the decoder
decoder.terminate()