You've already forked my-video-workflow
初次提交
This commit is contained in:
16
workflow/video.py
Normal file
16
workflow/video.py
Normal file
@ -0,0 +1,16 @@
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
|
||||
def get_video_real_duration(filename):
|
||||
ffmpeg_process = subprocess.Popen([
|
||||
"ffmpeg", "-hide_banner", "-i", filename, "-c", "copy", "-f", "null", "-"
|
||||
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
result = "0:0:0.0"
|
||||
for line in ffmpeg_process.stderr.readlines():
|
||||
match_result = re.findall("(?<= time=).+?(?= )", line.decode())
|
||||
if len(match_result) == 0:
|
||||
continue
|
||||
result = match_result.pop()
|
||||
return result
|
||||
|
Reference in New Issue
Block a user