Files
ac-ms-media-transcode/bin/probe-source.sh
Anton Afanasyeu 5ca8a9f539 Add lab restream pipeline with pirate_drift logo and lib/env.sh.
Encode-once/fanout scripts, HLS output, and single overloadable env source.
Commits assets/pirate_drift.png as default watermark for cluster runs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 15:27:24 +02:00

52 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# ffprobe → normalized source profile (draft SPEC-1 preview).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# shellcheck disable=SC1091
source "${ROOT}/lib/common.sh"
# shellcheck disable=SC1091
source "${ROOT}/lib/source.sh"
resolve_source "${1:-}"
require_cmd "${FFPROBE_BIN}"
probe_target="${SOURCE_URL}"
if [[ "${USE_YTDLP}" == "1" ]]; then
warn "page URL — ffprobe may fail; use a direct m3u8/mp4 URL or run encode-once"
fi
log "probing ${probe_target}"
"${FFPROBE_BIN}" -hide_banner -loglevel error \
-show_format -show_streams -print_format json \
"${probe_target}" | python3 -c '
import json, sys
data = json.load(sys.stdin)
fmt = data.get("format", {})
streams = data.get("streams", [])
v = next((s for s in streams if s.get("codec_type") == "video"), None)
a = next((s for s in streams if s.get("codec_type") == "audio"), None)
out = {
"duration": fmt.get("duration"),
"bitrate": fmt.get("bit_rate"),
"format": fmt.get("format_name"),
"video": None,
"audio": None,
}
if v:
out["video"] = {
"codec": v.get("codec_name"),
"width": v.get("width"),
"height": v.get("height"),
"fps": v.get("avg_frame_rate"),
"profile": v.get("profile"),
}
if a:
out["audio"] = {
"codec": a.get("codec_name"),
"channels": a.get("channels"),
"sample_rate": a.get("sample_rate"),
}
print(json.dumps(out, indent=2))
'