1

Okay, so after spending a lot of time encoding (or re-encoding) files to mp4's hoping they'd be compatible with iTunes, it turns out that iTunes won't play files with DTS or AC3/A52 audio, so I'm going to have to re-encode the audio on such files to AAC (where before I simply passed it through).

Anyway, I need a way to find all files with these audio types or, if it's easier, all MP4 files without AAC audio.

What is the best way to do this? Ideally I'd like to use Spotlight if I can, though I've tried several search criteria without much luck, but I'll also accept answers that use Terminal-based solutions, as I'll probably use ffmpeg to convert the audio anyway.

  • I'm working on a shell script. – Rnhmjoj Oct 25 '14 at 19:53
1

I made a shell script. This will print any file that has a different codec. Set the directory and extension to look for.

#!/bin/zsh
directory=~/Music
extension=m4a
codec=aac

find $directory -type f -name "*.$extension" -print0 | while read -d $'\0' file
do
    file_codec="$(ffprobe -v quiet -show_streams -print_format json $file | jq '.streams[0].codec_name')"
    [[ "${file_codec//\"}" != $codec ]] && echo $file
done

You need ffmpeg and jq. You can install both of them from homebrew.

  • 1
    Thanks for the help, I should have known it'd be something the ffmpeg toolbox! Just a note, I managed to simplify the command to not require jq with the following change: ffprobe -v quiet -show_streams -select_streams a -show_entries stream=codec_name "$file" | grep -F 'codec_name' | sed 's/^.*=//'; output should be checked in case it returns multiple lines (more than one audio stream) but should be able to handle cases where the audio isn't stream 0. – Haravikk Oct 29 '14 at 16:20
  • @Haravikk Great, I thought about sed but I'm not so good ad it. – Rnhmjoj Oct 29 '14 at 20:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .