|
|
@ -134,20 +134,21 @@ class TranscodeTools: |
|
|
|
return False |
|
|
|
|
|
|
|
async def h264toavi(self, source_file, delete_source_file = False): |
|
|
|
exec_string = "" |
|
|
|
exec_string = [] |
|
|
|
exec_cmd = "" |
|
|
|
if platform.system() == "Windows": |
|
|
|
exec_string += "" |
|
|
|
exec_cmd = f"{self.python_win32}" |
|
|
|
elif platform.system() == "Linux": |
|
|
|
exec_string += "wine " |
|
|
|
else: |
|
|
|
exec_cmd = "wine" |
|
|
|
exec_string.append(self.python_win32) |
|
|
|
raise Exception("Unknown platform to transcode") |
|
|
|
|
|
|
|
exec_string += str(self.python_win32) + " " |
|
|
|
exec_string += str(self.converter_script) + " " |
|
|
|
exec_string += str(source_file) |
|
|
|
print("execute", exec_string) |
|
|
|
proc = await asyncio.create_subprocess_exec(exec_string) |
|
|
|
await proc.wait() |
|
|
|
exec_string.append(self.converter_script) |
|
|
|
exec_string.append(source_file) |
|
|
|
|
|
|
|
print("execute", exec_cmd, exec_string) |
|
|
|
proc = await asyncio.create_subprocess_exec(exec_cmd, *exec_string) |
|
|
|
await proc.communicate() |
|
|
|
|
|
|
|
if delete_source_file: |
|
|
|
os.remove(source_file) |
|
|
@ -157,10 +158,10 @@ class TranscodeTools: |
|
|
|
raise Exception("AVI not be created") |
|
|
|
|
|
|
|
async def avitomp4(self, source_file, delete_source_file = False): |
|
|
|
exec_string = f"ffmpeg -y -i {source_file} {source_file}.mp4" |
|
|
|
exec_string = ["-y", "-i", source_file, f"{source_file}.mp4"] |
|
|
|
print("execute", exec_string) |
|
|
|
proc = await asyncio.create_subprocess_exec(exec_string) |
|
|
|
await proc.wait() |
|
|
|
proc = await asyncio.create_subprocess_exec("ffmpeg", *exec_string) |
|
|
|
await proc.communicate() |
|
|
|
|
|
|
|
if delete_source_file: |
|
|
|
os.remove(source_file) |
|
|
@ -196,6 +197,16 @@ class TranscodeTools: |
|
|
|
self.statuses[status.b64].done = True |
|
|
|
self.statuses[status.b64].outSize = os.path.getsize(mp4_file) |
|
|
|
|
|
|
|
async def transcode_test(self, raw_file): |
|
|
|
avi_file = await self.h264toavi(raw_file) |
|
|
|
mp4_file = await self.avitomp4(avi_file) |
|
|
|
|
|
|
|
def h264toavi_test(self, raw_file): |
|
|
|
loop = asyncio.get_event_loop() |
|
|
|
tasks = [loop.create_task(self.transcode_test(raw_file))] |
|
|
|
loop.run_until_complete(asyncio.wait(tasks)) |
|
|
|
loop.close() |
|
|
|
|
|
|
|
class Config: |
|
|
|
def __init__(self, config_name = "config.json", args = None) -> None: |
|
|
|
raw = load_config(config_name) |
|
|
@ -231,8 +242,11 @@ if __name__ == "__main__": |
|
|
|
import argparse |
|
|
|
parser = argparse.ArgumentParser() |
|
|
|
parser.add_argument("--no-hide-check", action="store_true") |
|
|
|
parser.add_argument("--test-h264toavi", type=str) |
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
if args.no_hide_check: |
|
|
|
Config(args = args) |
|
|
|
config = Config(args = args) |
|
|
|
if args.test_h264toavi: |
|
|
|
config.transcode_tools.h264toavi_test(args.test_h264toavi) |
|
|
|
sys.exit(0) |
|
|
|
|
|
|
|
sys.exit(0) |