Development > Scripting and Bash

[solved] ffmpeg on multiple .aac files in directory using find



I have a folder with multiple .aac audio files. I plan to use them in a car stereo that is very picky on accepting files.

So I found out using ffmpeg to clean out any unused metadata and possible other non-auditible information using this command:
ffmpeg -i 'input.aac' -vn -c:a copy 'output.aac'

I want to be able to do this for several files at once. According to this thread in unix.stackexchange forum, it should be easilly done by using the find command.

However - I have tried several variation of the command (using the example from unix.stackexchange forum), but without any success (ffmpeg claim error about file existing). This is the commands I have tried so far:

--- Code: ---find . -name "*.aac" -exec ffmpeg -i {}  -vn -c:a copy 2_{}
find . -name "*.aac" -exec ffmpeg -i {}  -vn -c:a copy 2_{} \;
find . -name "*.aac" -exec ffmpeg -i {}  -vn -c:a copy NEW{} \;
find . -name "*.aac" -exec ffmpeg -i {}  -vn -c:a copy NEW{}\;
find . -name "*.aac" -exec ffmpeg -i {}  -vn -c:a copy NEW{} \;
find . -name "*.aac" -exec ffmpeg -i '{}'  -vn -c:a copy 'NEW{}'\;
--- End code ---

I usually got an error message like this (for every file):
NEW./input-file-name.aac: No such file or directory

I cannot 'see' the command that ffmpeg actually receive, so I cannot tell if there is an obviously error.


I have got help on this on a local forum. I didn't get a solution that I could just enter directly in Terminal, but I got help with a sample shell script that I managed to:

* Run ffmpeg on all files in current dir
* Using touch command to set tate for converted files similar to the original file
* Renaming files so that the original files change the name.
--- Code: ---#!/bin/bash
for i in *.aac
    echo ""
    ffmpeg -i "$i" -vn -c:a copy "NEW_$i"
    touch -cm --reference="$i" "NEW_$i"
    mv "$i" "OLD $i"
    mv "NEW_$i" "$i"
    echo ""
--- End code ---

Nice :)


[0] Message Index

Go to full version