Skip to content

Instantly share code, notes, and snippets.

@oddmario
Last active December 10, 2024 12:23
Show Gist options
  • Select an option

  • Save oddmario/d0b2b0651af9d97ad0cba7aa35976ba0 to your computer and use it in GitHub Desktop.

Select an option

Save oddmario/d0b2b0651af9d97ad0cba7aa35976ba0 to your computer and use it in GitHub Desktop.

Revisions

  1. oddmario revised this gist Dec 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion extract_original_audio.sh
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,6 @@ if [ -z "$track" ]; then
    fi

    # Use the detected audio track index
    ffmpeg -i "$input" -vn -acodec aac -map 0:a:"$track" "$output"
    ffmpeg -i "$input" -vn -acodec aac -map 0:"$track" "$output"

    echo "File processed successfully: $output"
  2. oddmario created this gist Dec 10, 2024.
    24 changes: 24 additions & 0 deletions extract_original_audio.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/bash

    # Check if the correct number of arguments is provided
    if [ "$#" -ne 2 ]; then
    echo "Usage: $0 <input_file> <output_file>"
    exit 1
    fi

    input="$1"
    output="$2"

    # Find the "original" audio track dynamically
    track=$(ffprobe -i "$input" -v error -select_streams a \
    -show_entries stream=index:stream_tags=title -of csv=p=0 | grep -i "original" | cut -d ',' -f1)

    if [ -z "$track" ]; then
    echo "No 'original' audio track found!"
    exit 1
    fi

    # Use the detected audio track index
    ffmpeg -i "$input" -vn -acodec aac -map 0:a:"$track" "$output"

    echo "File processed successfully: $output"