mirror of
git://f0xx.org/ac/ac-ms-media-transcode
synced 2026-07-29 03:37:39 +03:00
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>
This commit is contained in:
81
bin/encode-only.sh
Executable file
81
bin/encode-only.sh
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
# Encode once → local recording (+ optional HLS). No named-pipe fanout stage.
|
||||
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"
|
||||
# shellcheck disable=SC1091
|
||||
source "${ROOT}/lib/filters.sh"
|
||||
# shellcheck disable=SC1091
|
||||
source "${ROOT}/lib/outputs.sh"
|
||||
|
||||
resolve_source "${1:-}"
|
||||
require_cmd "${FFMPEG_BIN}"
|
||||
require_logo
|
||||
ensure_storage
|
||||
|
||||
compute_layout() {
|
||||
VIDEO_INPUT="0:v"
|
||||
if [[ ${#AUDIO_INPUT_ARGS[@]} -gt 0 ]]; then
|
||||
AUDIO_MAP_INPUT=1
|
||||
LOGO_INPUT=2
|
||||
else
|
||||
AUDIO_MAP_INPUT=0
|
||||
LOGO_INPUT=1
|
||||
fi
|
||||
}
|
||||
|
||||
compute_layout
|
||||
RECORD_PATH="$(next_record_path)"
|
||||
LOG_FILE="${STORAGE_DIR}/encode.log"
|
||||
build_filter_complex "${VIDEO_INPUT}" "${LOGO_INPUT}:v"
|
||||
MAP_V="$(map_video_out)"
|
||||
MAP_A="$(map_audio_out)"
|
||||
|
||||
build_record_tee() {
|
||||
local record="$1"
|
||||
local parts=()
|
||||
parts+=("$(file_tee_entry "${record}")")
|
||||
if [[ -n "${HLS_OUTPUT_DIR}" ]]; then
|
||||
parts+=("$(hls_tee_entry "${HLS_OUTPUT_DIR}")")
|
||||
fi
|
||||
local IFS='|'
|
||||
echo "${parts[*]}"
|
||||
}
|
||||
|
||||
TEE_SPEC="$(build_record_tee "${RECORD_PATH}")"
|
||||
|
||||
run_ffmpeg() {
|
||||
"${FFMPEG_BIN}" -hide_banner -loglevel info \
|
||||
-rtbufsize 256M -probesize 100M -analyzeduration 250M \
|
||||
"$@" \
|
||||
-i "${LOGO_PATH}" \
|
||||
"${FFMPEG_TS_FLAGS[@]}" \
|
||||
-filter_complex "${FILTER_COMPLEX}" \
|
||||
-map "${MAP_V}" -map "${MAP_A}" \
|
||||
-threads "${THREADS}" -framerate "${FPS}" -r "${FPS}" \
|
||||
-s "${RES}" ${VCODEC} ${PRESET} ${BITRATE} ${ACODEC} -bufsize "${BUFSIZE}" \
|
||||
-f tee "${TEE_SPEC}" >> "${LOG_FILE}" 2>&1
|
||||
}
|
||||
|
||||
log "encode-only → ${RECORD_PATH}"
|
||||
[[ -n "${HLS_OUTPUT_DIR}" ]] && log "HLS → ${HLS_OUTPUT_DIR}"
|
||||
|
||||
if [[ "${USE_YTDLP}" == "1" ]]; then
|
||||
require_cmd "${YTDLP_BIN}"
|
||||
mapfile -d '' -t YTDLP_CMD < <(build_ytdlp_pipeline)
|
||||
"${YTDLP_CMD[@]}" 2>>"${LOG_FILE}" | \
|
||||
run_ffmpeg -thread_queue_size "${THREAD_QUEUE_SIZE}" -i pipe:0 \
|
||||
"${AUDIO_INPUT_ARGS[@]}"
|
||||
else
|
||||
read_rate_flag
|
||||
run_ffmpeg \
|
||||
"${RE_FLAG[@]}" \
|
||||
-thread_queue_size "${THREAD_QUEUE_SIZE}" \
|
||||
-reconnect_on_network_error 1 -reconnect_streamed 1 -reconnect_delay_max 5 \
|
||||
-i "${SOURCE_URL}" \
|
||||
"${AUDIO_INPUT_ARGS[@]}"
|
||||
fi
|
||||
Reference in New Issue
Block a user