python3保存mp4 avi转mp4
【摘要】 动态库名称:
openh264-1.8.0-win64.dll
# !/usr/bin/env python# -*-coding:utf-8-*-import datetimeimport timeimport cv2import os cam = cv2.VideoCapture(0)time_now =time.time()# fourcc = ...
动态库名称:
openh264-1.8.0-win64.dll
-
-
# !/usr/bin/env python
-
# -*-coding:utf-8-*-
-
import datetime
-
import time
-
import cv2
-
import os
-
-
-
cam = cv2.VideoCapture(0)
-
time_now =time.time()
-
# fourcc = cv2.VideoWriter_fourcc(*'avc1')
-
os.makedirs('capture', exist_ok=True)
-
-
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
-
video_out = None
-
-
while True:
-
ret, frame = cam.read()
-
if video_out:
-
video_out.write(frame)
-
cv2.imshow("asdf", frame)
-
cv2.waitKey(1)
-
if video_out is None or time.time() - time_now > 10:
-
if video_out:
-
print("save", video_path)
-
video_out.release()
-
video_out = None
-
timestr = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
-
video_path = 'capture/' +timestr + '.mp4'
-
video_out = cv2.VideoWriter(video_path, fourcc, 30.0, (640, 480))
-
time_now = time.time()
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/80195310
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)