Commit c82d0178 authored by mac's avatar mac

total

parent a7a18209
...@@ -103,17 +103,24 @@ def video2comix(args): ...@@ -103,17 +103,24 @@ def video2comix(args):
print('video open status:', vc.isOpened()) print('video open status:', vc.isOpened())
# 获取视频宽度 # 获取视频宽度
frame_width = int(cv2.get(cv2.CAP_PROP_FRAME_WIDTH)) frame_width = int(vc.get(cv2.CAP_PROP_FRAME_WIDTH))
# 获取视频高度 # 获取视频高度
frame_height = int(cv2.get(cv2.CAP_PROP_FRAME_HEIGHT)) frame_height = int(vc.get(cv2.CAP_PROP_FRAME_HEIGHT))
print('video w,h:', str(frame_width), ',', str(frame_height)) print('video w,h:', str(frame_width), ',', str(frame_height))
#total frames num
numFrames = int(vc.get(cv2.CAP_PROP_FRAME_COUNT))
print('video total Frames num:', str(numFrames))
# fps # fps
fps = vc.get(cv2.CAP_PROP_FPS) fps = vc.get(cv2.CAP_PROP_FPS)
print('video fps:', str(fps)) print('video fps:', str(fps))
# target coim fps # target coim fps
fps_flow = args.fps # fps / 2 fps_flow = args.fps # fps / 2
print('video fps:', str(fps_flow)) print('video fps:', str(fps_flow))
# MPEG can not play in web # MPEG can not play in web
fourcc = cv2.VideoWriter_fourcc(*"H264") fourcc = cv2.VideoWriter_fourcc(*"H264")
wh = (frame_width, frame_height) wh = (frame_width, frame_height)
...@@ -128,6 +135,10 @@ def video2comix(args): ...@@ -128,6 +135,10 @@ def video2comix(args):
while vc.isOpened(): while vc.isOpened():
vc.set(cv2.CAP_PROP_POS_FRAMES, n) # 截取指定帧数 vc.set(cv2.CAP_PROP_POS_FRAMES, n) # 截取指定帧数
n = n + step #跳帧 n = n + step #跳帧
if n >= numFrames:
print('video2comix - read frame is over')
break
su, frame = vc.read() su, frame = vc.read()
if frame is None: if frame is None:
print('video2comix - read frame is none') print('video2comix - read frame is none')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment