python调用系统ffmpeg实现视频截图、http发送

2020-06-25 07:29:34 来源:易采站长站 作者:易采站长站整理


localtime=time.time() #获取当前系统时间
t=localtime-filetime #两者差值
#判断差值是否小于300s
if t<=subtime:
print t,filePath
filename=unicode(filename, 'utf8') #下载视频名称
#生成视频md5
str_md5= 'md5sum'+' ' + filePath +' '+ "| awk '{print $1}'"
video_md5 = os.popen(str_md5).readline(32)
#拼接命令行,
str_video= "ffmpeg -ss 0:1:00 -i "+" " +filePath + " "+"-r 0.01 -f image2 "+imagedir+video_md5+"-image-%5d.jpeg"
images = os.popen(str_video) # 调用命令行生成截图
print str_video

#生成黑名单截图
def create_black_image(black_dir):
#扫描视频目录生成截图
for parent, dirnames, filenames in os.walk(black_dir): # 三个参数:分别返回1.父目录 2.所有文件夹名字(不含路径) 3.所有文件名字
for filename in filenames: # 输出文件信息
video_path = os.path.join(parent, filename) # 输出文件路径信息
filePath = unicode(video_path, 'utf8') #中文编码
filetime= os.path.getmtime(filePath) #获取修改时间
localtime=time.time() #获取当前系统时间
t=localtime-filetime #两者差值
#判断差值是否小于300s
if t<=subtime:
print t,filePath
filename=unicode(filename, 'utf8') #下载视频名称
#生成视频md5
str_md5= 'md5sum'+' ' + filePath +' '+ "| awk '{print $1}'"
video_md5 = os.popen(str_md5).readline(32)
#拼接命令行,
str_video= "ffmpeg -ss 0:1:00 -i "+" " +filePath + " "+"-r 0.01 -f image2 "+imagedir+video_md5+"-image-%5d.jpeg"
images = os.popen(str_video) # 调用命令行生成截图
print str_video

#生成白名单截图
def create_white_image(white_dir):
#扫描视频目录生成截图
for parent, dirnames, filenames in os.walk(white_dir): # 三个参数:分别返回1.父目录 2.所有文件夹名字(不含路径) 3.所有文件名字
for filename in filenames: # 输出文件信息
video_path = os.path.join(parent, filename) # 输出文件路径信息
filePath = unicode(video_path, 'utf8') #中文编码
filetime= os.path.getmtime(filePath) #获取修改时间
localtime=time.time() #获取当前系统时间
t=localtime-filetime #两者差值
#判断差值是否小于300s
if t<=subtime:
print t,filePath
filename=unicode(filename, 'utf8') #下载视频名称
#生成视频md5
str_md5= 'md5sum'+' ' + filePath +' '+ "| awk '{print $1}'"
video_md5 = os.popen(str_md5).readline(32)
#拼接命令行,
str_video= "ffmpeg -ss 0:1:00 -i "+" " +filePath + " "+"-r 0.01 -f image2 "+imagedir+video_md5+"-image-%5d.jpeg"
images = os.popen(str_video) # 调用命令行生成截图
print str_video
#发送图片进程
def send_image(imagedir):
#扫描图片路径

暂时禁止评论

微信扫一扫

易采站长站微信账号