From 5e4196a2c721fbd0f3ad64a1016660a3e26714b1 Mon Sep 17 00:00:00 2001 From: RealStickman Date: Fri, 16 Dec 2022 14:51:10 +0100 Subject: [PATCH] WIP add check if duration is set/valid --- main.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.py b/main.py index 291926a..f63cb0c 100755 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # ffmpeg wrapper +import subprocess import ffmpy # argument parsing @@ -182,3 +183,28 @@ if execute: ff.run() else: print(ff.cmd) + +# NOTE check all files for an intact/valid duration +# Valid file example output: +# { +# "format": { +# "duration": "1425.058000" +# } +# } +# Invalid file: +# { +# "format": { +# +# } +# } +ff = ffmpy.FFprobe( + inputs={outputfile: None}, + global_options=("-show_entries format=duration -v quiet -print_format json"), +) + +proc = subprocess.Popen( + ff.cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True +) + +# TODO continue here +print(proc.stdout.read().rstrip().decode("utf8"))