diff --git a/nulrdcscripts/tools/ffprobeExtraction/__init__.py b/nulrdcscripts/tools/ffprobeExtraction/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nulrdcscripts/tools/ffprobeExtraction/main.py b/nulrdcscripts/tools/ffprobeExtraction/main.py new file mode 100644 index 0000000..6a392ea --- /dev/null +++ b/nulrdcscripts/tools/ffprobeExtraction/main.py @@ -0,0 +1,38 @@ +import os +import progressbar +import subprocess +import time +from nulrdcscripts.tools.ffprobeExtraction.params import args + + +def main(): + # Check if the input file exists + if not os.path.isfile(args.input_path): + print(f"Error: The input file '{args.input_path}' does not exist.") + return + + if args.output_format == "JSON" or args.output_format == "json": + output_format = "json" + elif args.output_format == "XML" or args.output_format == "xml": + output_format = "xml" + else: + raise ValueError( + "This file format is not supported by this script for ffprobe data extraction." + ) + + output_path = os.path.splitext(args.input_path)[0] + {output_format} + + input_path = os.path.abspath(args.input_path) + output_path = os.path.abspath(output_path) + + command = f'ffprobe -f lavfi -i "movie={input_path},signalstats" -show_frames -show_streams -of {output_format} > {output_path}' + bar = progressbar.ProgressBar(max_value=progressbar.UnknownLength) + for i in range(100): + time.sleep(0.1) + bar.update(i) + + subprocess.run(command) + + +if __name__ == "__main__": + main() diff --git a/nulrdcscripts/tools/ffprobeExtraction/params.py b/nulrdcscripts/tools/ffprobeExtraction/params.py new file mode 100644 index 0000000..7292984 --- /dev/null +++ b/nulrdcscripts/tools/ffprobeExtraction/params.py @@ -0,0 +1,23 @@ +import argparse + +parser = argparse.ArgumentParser() + +parser.add_argument( + "--input", + "-i", + action="store", + dest="input_path", + type=str, + help="full path to input file", +) + +parser.add_argument( + "-of", + "--outputformat", + action="store", + dest="outputformat", + default="json", + type=str, + help="format that you want the ffprobe report to be in. JSON is the default and the other accepted value is XML", +) +args = parser.parse_args() diff --git a/pyproject.toml b/pyproject.toml index 41a3913..2d8c2ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nul-rdc-scripts" -version = "0.5.2" +version = "0.6.0" description = "Scripts for NUL RDC Digitization Team" authors = [ "Northwestern University Libraries ", @@ -29,6 +29,7 @@ md5 = 'nulrdcscripts.tools.md5generation.main:main' trim = 'nulrdcscripts.tools.videotrimmer.main:main' micro = 'nulrdcscripts.ingestMicro.ingest:main' meta = 'nulrdcscripts.tools.generatemetadataTEMP.main:main' +ffprobedata = 'nulrdcscripts.tools.ffprobeExtract.main:main' [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api"