27 lines
787 B
Python
27 lines
787 B
Python
from typing import Optional, IO
|
|
|
|
from entity.ffmpeg import FfmpegTask
|
|
|
|
|
|
def start_render(ffmpeg_task: FfmpegTask):
|
|
print(ffmpeg_task)
|
|
|
|
def handle_ffmpeg_output(stdout: Optional[IO[bytes]]) -> str:
|
|
out_time = "0:0:0.0"
|
|
if stdout is None:
|
|
print("[!]STDOUT is null")
|
|
return out_time
|
|
speed = "0"
|
|
while True:
|
|
line = stdout.readline()
|
|
if line == b"":
|
|
break
|
|
if line.strip() == b"progress=end":
|
|
# 处理完毕
|
|
break
|
|
if line.startswith(b"out_time="):
|
|
out_time = line.replace(b"out_time=", b"").decode().strip()
|
|
if line.startswith(b"speed="):
|
|
speed = line.replace(b"speed=", b"").decode().strip()
|
|
print("[ ]Speed:", out_time, "@", speed)
|
|
return out_time |