Currently, I have a simple script that will detect video audio codec using ffmpeg and output a message specifing if the codec is mp4 or aac. Here is my code:
#!/bin/bash
for i in *.mp4; do
OUTPUT=$(ffmpeg -i '$i' 2>&1 | grep -o 'Audio:.*' | cut -f2 -d' ' | awk '{print $0}' | tr -d ,)
if [[ $OUTPUT == "mp3" ]]; then
echo "${i} = audio codec mp3"
fi
if [[ $OUTPUT == "aac" ]]; then
echo "${i} = audio codec aac"
fi
done
But this script isn't working! There are no errors and I don't know what should I do to solve this. Also, ffmpeg -i <input.mp4> 2>&1 | grep -o 'Audio:.*' | cut -f2 -d' ' | awk '{print $0}' | tr -d ,
returns aac or mp3, this line is working perfeclty! I guess that the problem is related to if case
, but as I've said, I'm unable to solve this alone, can you help me?
Thank you