Commit 6ae75e37 authored by mac's avatar mac

c

parent a2e8181d
Pipeline #391 canceled with stages
......@@ -135,6 +135,11 @@ def video2comix(args):
print('miss param: filename')
return
i = 0 #写入的帧数计数值
readFrameNum = 0 #要读取的帧数
totalTime = 0 #总时间
device = args.device
net = Generator()
......@@ -172,9 +177,14 @@ def video2comix(args):
print('video total Frames num:', str(numFrames))
step = fps / fps_flow #根据fps算要跳几帧,比如:24fpx/5fpx=4,即每4帧读取下,1秒大概读取4~5帧
totalNumFrames = numFrames / step
totalNumFrames = int(numFrames / step)
print('video output total Frames num:', str(totalNumFrames))
if args.total_seconds != 0:
totalNumFrames = int(args.seconds*fps_flow)
if args.start_seconds != 0:
readFrameNum = int(args.start_seconds*fps)
# MPEG can not play in web
......@@ -185,17 +195,17 @@ def video2comix(args):
wh = (to_32s(frame_width), to_32s(frame_height))
print('video output w,h:', str(wh))
flow_video = cv2.VideoWriter(outputmp4, fourcc, fps_flow, wh)
i = 0
n = 0 #帧数
totalTime = 0
imgname = uuid.uuid4().hex
while vc.isOpened():
vc.set(cv2.CAP_PROP_POS_FRAMES, n) # 截取指定帧数
n = n + step #跳帧
if n >= numFrames:
print('video2comix - read frame is over')
vc.set(cv2.CAP_PROP_POS_FRAMES, readFrameNum) # 截取指定帧数
readFrameNum = readFrameNum + step #跳帧
if readFrameNum >= numFrames:
print('video2comix - read totalNumframes is over')
break
if i >= totalNumFrames:
print('video2comix - output totalNumFrames is over')
break
su, frame = vc.read()
if frame is None:
print('video2comix - read frame is none')
......@@ -279,6 +289,22 @@ if __name__ == '__main__':
help="fps >0 and < 20"
)
parser.add_argument(
'--total_seconds',
type=int,
default=5,
help="senonds >= 0 and < 60"
)
parser.add_argument(
'--start_seconds',
type=int,
default=0,
help="senonds >= 0 and < 60"
)
args = parser.parse_args()
time=video2comix(args)
......
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