#!/bin/bash # Normalize video to Linear Void required profile. # Output: H.264/AAC, 30fps constant, 2s keyframes, yuv420p, 48kHz audio. # Usage: ./normalize.sh [output] set -e INPUT="$1" if [ -z "$INPUT" ]; then echo "Usage: $0 [output-file]" echo " Normalizes video to Linear Void profile: H.264/AAC, 30fps, 2s keyframes" exit 1 fi if [ ! -f "$INPUT" ]; then echo "Error: input file not found: $INPUT" exit 1 fi OUTPUT="${2:-${INPUT%.*}-normalized.mp4}" CRF="${NORMALIZE_CRF:-21}" PRESET="${NORMALIZE_PRESET:-medium}" AUDIO_BITRATE="${NORMALIZE_AUDIO_BITRATE:-160k}" echo "=== Linear Void Video Normalization ===" echo " Input: $INPUT ($(du -h "$INPUT" | cut -f1))" echo " Output: $OUTPUT" echo " CRF: $CRF" echo " Preset: $PRESET" echo " Audio rate: $AUDIO_BITRATE" echo "" # Probe input echo "--- Input Properties ---" ffprobe -v error -show_entries stream=codec_name,width,height,r_frame_rate,pix_fmt,sample_rate,channels \ -of default=noprint_wrappers=1 "$INPUT" 2>&1 echo "" # Normalize echo "--- Normalizing ---" ffmpeg -y -i "$INPUT" \ -c:v libx264 -preset "$PRESET" -crf "$CRF" \ -r 30 -g 60 -keyint_min 60 -sc_threshold 0 \ -pix_fmt yuv420p \ -c:a aac -b:a "$AUDIO_BITRATE" -ar 48000 -ac 2 \ -movflags +faststart \ "$OUTPUT" echo "" echo "--- Output Properties ---" ffprobe -v error -show_entries stream=codec_name,width,height,r_frame_rate,pix_fmt,sample_rate,channels \ -of default=noprint_wrappers=1 "$OUTPUT" 2>&1 echo "" echo "=== Normalization Complete ===" echo " Output: $OUTPUT ($(du -h "$OUTPUT" | cut -f1))" echo "" echo "Verify with: ffprobe -v error -show_entries stream=codec_name,r_frame_rate,pix_fmt -of default=noprint_wrappers=1 $OUTPUT"