Search This Blog

Thursday, November 9, 2023

[Ubuntu] Convert mp4 video to aac audio

 

#!/bin/bash

# Define the target directory
directory="."

# Check if the target is not a directory
if [ ! -d "$directory" ]; then
  exit 1
fi

# Loop through files in the target directory
for file in "$directory"/*; do
  if [ -f "$file" ]; then
    if [ "${file##*.}" == "mp4" ]; then
        echo "${file%.*}.aac"
        ffmpeg -i "$file" -c:a aac -b:a 128k -vn "${file%.*}.aac"
    fi
  fi
done