From 3db82986c568d2f593f2e849f065dfed9e934f54 Mon Sep 17 00:00:00 2001 From: Paul Tunison Date: Wed, 16 Oct 2024 13:53:02 -0400 Subject: [PATCH 1/2] Some high level helper scripts for BBN data extraction and ffprobe calls --- scripts/extract_bbn_video_archives.bash | 21 +++++++++++++++++++++ scripts/extract_bbn_video_ffprobe.bash | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 scripts/extract_bbn_video_archives.bash create mode 100755 scripts/extract_bbn_video_ffprobe.bash diff --git a/scripts/extract_bbn_video_archives.bash b/scripts/extract_bbn_video_archives.bash new file mode 100755 index 000000000..d7752b7f4 --- /dev/null +++ b/scripts/extract_bbn_video_archives.bash @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Simple script to unarchive a bunch of ZIP file contents into subdirectories +# mirroring the name of the ZIP archive. +# +# Ensure the current directory contains the archives to be extracted, and that +# they are named in such a way as to allow for extraction into a subdirectory +# with the same name (e.g., "foo-1.0.zip" will extract into "./foo-1.0"). +# + +for NAME in *.zip +do + echo "+++ Starting $NAME +++" + BNAME="$(basename "$NAME" .zip)" + if [[ ! -d "${BNAME}" ]] + then + mkdir "$BNAME"; + unzip -d "$BNAME" "$NAME" + fi + echo "--- Finished $NAME ---" +done diff --git a/scripts/extract_bbn_video_ffprobe.bash b/scripts/extract_bbn_video_ffprobe.bash new file mode 100755 index 000000000..aceec0047 --- /dev/null +++ b/scripts/extract_bbn_video_ffprobe.bash @@ -0,0 +1,21 @@ +#!/bin/bash +shopt -s globstar nullglob + +DATAPATH="${DATAPATH:-"/home/local/KHQ/paul.tunison/data/darpa-ptg/bbn_data/lab_data-golden"}" +WORKDIR="${WORKDIR:-"/home/local/KHQ/paul.tunison/data/darpa-ptg/bbn_data/lab_data-working"}" + +for F in "${DATAPATH}"/**/*.mp4 +do + echo $F + F_rel="$(realpath --relative-to="${DATAPATH}" "$F")" + output_dirpath="$(realpath -m "${WORKDIR}/$(dirname "$F_rel")")" + output_filepath="${output_dirpath}/$(basename "$F" .mp4).probe.txt" + mkdir -p "${output_dirpath}" + if [[ ! -f "${output_filepath}" ]] + then + ffprobe "${F}" 2>&1 | tee "${output_filepath}" + fi +done + +# Collect all probed video streams metadata summary for resolution and fps info +# $> grep -rin "Stream.*: Video" ../lab_data-working/ >../probe_summary.txt From 1d51f562e43bf1b3d5dd0692f881a7e467a6ce57 Mon Sep 17 00:00:00 2001 From: Paul Tunison Date: Thu, 17 Oct 2024 12:41:09 -0400 Subject: [PATCH 2/2] Add comment/example to ffprobe script --- scripts/extract_bbn_video_ffprobe.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/extract_bbn_video_ffprobe.bash b/scripts/extract_bbn_video_ffprobe.bash index aceec0047..a36e63259 100755 --- a/scripts/extract_bbn_video_ffprobe.bash +++ b/scripts/extract_bbn_video_ffprobe.bash @@ -1,4 +1,15 @@ #!/bin/bash +# +# This is a convenience script to invoke ffprobe on all of the MP4 files found +# under a directory, and then log the output of ffprobe in a symmetric location +# in a working directory. This is due to expecting the MP4 source location to +# be a read-only "golden" space that we don't want to write computed files to. +# +# Example: +# $ export DATAPATH=/path/to/data +# $ export WORKDIR=/path/to/workdir +# $ ./extract_bbn_video_ffprobe.bash +# shopt -s globstar nullglob DATAPATH="${DATAPATH:-"/home/local/KHQ/paul.tunison/data/darpa-ptg/bbn_data/lab_data-golden"}"