From 3689ecd8d4ea8db4cd6905f1184ec16e460e71ef 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 --- easyffmpeg/main.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/easyffmpeg/main.py b/easyffmpeg/main.py index 291926a6..f63cb0c3 100755 --- a/easyffmpeg/main.py +++ b/easyffmpeg/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"))