Skip to content

Commit

Permalink
Merge pull request #454 from Purg/dev/bbn-data-scripts
Browse files Browse the repository at this point in the history
Some high level helper scripts for BBN data extraction and ffprobe calls
  • Loading branch information
Purg authored Oct 17, 2024
2 parents fec1b91 + 1d51f56 commit 947db76
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/extract_bbn_video_archives.bash
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions scripts/extract_bbn_video_ffprobe.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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"}"
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

0 comments on commit 947db76

Please sign in to comment.