#!/bin/sh
#
# ffmeta - view media metadata using ffprobe
# accepts filenames from args or stdin (one file per line)

# TODO(2025-06-27): only print header when interactive

if test "$#" -eq 0; then
  cat
else
  printf '%s\n' "$@"
fi | while read -r f; do
  hi "${f}"
  # loglevel: from 32 shows stream details (steps of 8), so only for small groups
  find "${f}" -type f -exec ffprobe -hide_banner \
    -loglevel $((34 - $#)) -print_format default=noprint_wrappers=1 \
    -show_format -pretty {} \;
done | less
