basic cpu encode support

This commit is contained in:
2024-11-27 16:47:39 +08:00
parent a8abb92b84
commit 9139727dc6
3 changed files with 136 additions and 23 deletions

View File

@ -1,3 +1,5 @@
import os
from datetime import datetime
from typing import Optional, IO
from entity.ffmpeg import FfmpegTask
@ -5,6 +7,8 @@ from entity.ffmpeg import FfmpegTask
def start_render(ffmpeg_task: FfmpegTask):
print(ffmpeg_task)
print(ffmpeg_task.get_ffmpeg_args())
os.system("ffmpeg.exe "+" ".join(ffmpeg_task.get_ffmpeg_args()))
def handle_ffmpeg_output(stdout: Optional[IO[bytes]]) -> str:
out_time = "0:0:0.0"
@ -24,4 +28,8 @@ def handle_ffmpeg_output(stdout: Optional[IO[bytes]]) -> str:
if line.startswith(b"speed="):
speed = line.replace(b"speed=", b"").decode().strip()
print("[ ]Speed:", out_time, "@", speed)
return out_time
return out_time
def duration_str_to_float(duration_str: str) -> float:
_duration = datetime.strptime(duration_str, "%H:%M:%S.%f") - datetime(1900, 1, 1)
return _duration.total_seconds()