Skip to content

FFProbe Data Extraction Tool #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
38 changes: 38 additions & 0 deletions nulrdcscripts/tools/ffprobeExtraction/main.py
Original file line number Diff line number Diff line change
@@ -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()
23 changes: 23 additions & 0 deletions nulrdcscripts/tools/ffprobeExtraction/params.py
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down Expand Up @@ -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"