Last active
March 22, 2025 03:57
-
-
Save w3spi5/60c35076fd79135903311e377cd151d3 to your computer and use it in GitHub Desktop.
Hi8/VHS digitized video enhancement script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Hi8 digitized video enhancement script | |
| # Created on March 22, 2025 | |
| # Enhancement parameters configuration | |
| SATURATION=1.2 # Saturation value (1.0 = normal, 1.2 = +20%) | |
| CONTRAST=1.1 # Contrast value (1.0 = normal, 1.1 = +10%) | |
| BRIGHTNESS=0.05 # Brightness adjustment (-1.0 to 1.0) | |
| VIDEO_DENOISING="4:3:6:3" # Denoising parameters (strength:spatial:temporal:spatial) | |
| VIDEO_QUALITY=18 # CRF - lower = better quality (18-23 recommended) | |
| AUDIO_BITRATE="192k" # Audio bitrate in kbps | |
| PRESET="medium" # Encoding preset (faster, medium, slow) | |
| # Source directory containing original videos | |
| SOURCE_DIR="$HOME/Hi8_Tapes/Original" | |
| # Destination directory for enhanced videos | |
| DESTINATION_DIR="$HOME/Hi8_Tapes/Enhanced" | |
| # Create directories if they don't exist | |
| mkdir -p "$SOURCE_DIR" | |
| mkdir -p "$DESTINATION_DIR" | |
| # Function to process a video file | |
| process_video() { | |
| source_file="$1" | |
| filename=$(basename "$source_file") | |
| name_without_extension="${filename%.*}" | |
| destination_file="$DESTINATION_DIR/${name_without_extension}_enhanced.mp4" | |
| echo "Processing: $filename" | |
| echo "Output to: ${name_without_extension}_enhanced.mp4" | |
| # FFmpeg command with all filters | |
| ffmpeg -i "$source_file" \ | |
| -vf "eq=saturation=$SATURATION:contrast=$CONTRAST:brightness=$BRIGHTNESS,hqdn3d=$VIDEO_DENOISING,yadif=0:-1:1" \ | |
| -af "highpass=200,dynaudnorm" \ | |
| -c:v libx264 -crf $VIDEO_QUALITY -preset $PRESET \ | |
| -c:a aac -b:a $AUDIO_BITRATE \ | |
| "$destination_file" | |
| # Success check | |
| if [ $? -eq 0 ]; then | |
| echo "✓ Processing successful: $filename" | |
| else | |
| echo "✗ Processing failed: $filename" | |
| fi | |
| echo "----------------------------------------" | |
| } | |
| # Check if a specific file is provided as an argument | |
| if [ $# -gt 0 ]; then | |
| # Process only the specified file | |
| process_video "$1" | |
| else | |
| # Count total number of files to process | |
| total_files=$(find "$SOURCE_DIR" -type f \( -name "*.mkv" -o -name "*.mp4" -o -name "*.avi" \) | wc -l) | |
| processed_files=0 | |
| # Process all video files in the source directory | |
| echo "Starting batch processing: $total_files files found" | |
| echo "==========================================" | |
| find "$SOURCE_DIR" -type f \( -name "*.mkv" -o -name "*.mp4" -o -name "*.avi" \) | while read -r file; do | |
| process_video "$file" | |
| processed_files=$((processed_files + 1)) | |
| echo "Progress: $processed_files/$total_files" | |
| done | |
| echo "Batch processing completed. $processed_files/$total_files files processed." | |
| fi | |
| echo "All videos have been processed and saved to: $DESTINATION_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment