You are not logged in.
Hi all,
I'm trying to run FFMPEG on the multiple results of FIND
i suppose the general syntax is:
find [location] [expression] -exec FFMPEG ... {} \
but I don't know how to make it so that the names of the files are the same except for different extensions.
how do I run a program with multiple filenames as inputs, while retaining the same filenames as output except for changing the extensions
for example: ffmpeg audio1.mp3 audio1.ogg
but I want to do this with multiple files
Best,
Alan
Last edited by beitme (2013-09-15 01:59:46)
Offline
Have you tried e.g.
$ find . -name "foo.*" -o -name "bar.*"
./foo.ogg
./bar.mp4
./foo.mp4
./bar.mp3Offline
Not a Sysadmin issue, moving to NC...
Offline
Have you tried e.g.
$ find . -name "foo.*" -o -name "bar.*" ./foo.ogg ./bar.mp4 ./foo.mp4 ./bar.mp3
Hi,
I'm not asking how to find multiple files, I'm asking how to process mutiple files and retain the same filename as output but with a different extension
Offline
Can you give an example? I don't understand what you mean.
If you want to turn audio1.mp3 into audio1.ogg using ffmpeg, maybe a 'for' loop would do. Loop over the input files and for each of these files tell ffmpeg to do something.
Offline
yes that's what I want.
I've never written a script before, but I know how to read the ones on my computer.
I'm working with a for loop right now, but I can't figure out how to use it with FIND
so I'm looking for something like this:
run FIND, output will result in multiple files
run the output of files into FFMPEG, and I want the output to result in the same filenames but with different extensions (.mp3 into .ogg)
three problems I face:
1) getting find to work with a for loop
2) renaming each file into one with the same basename but different extension
3) should I use xargs or -exec???
if I run the for loop before or after FIND, i don't get the proper results
Offline
Have you tried something like https://wiki.archlinux.org/index.php/Co … lac_to_Mp3
#!/bin/bash
for f in *.flac; do
ffmpeg -i "$f" -qscale:a 0 "${f[@]/%flac/mp3}"
done1. I don't know if all input files are of the same extension, if not, maybe process all *.foo files first, next process all *.bar etc. editing the script to change from foo to bar.
2. Converting files from one lossy format to another is not optimal.
Offline
right but how do I run this with the output of FIND???
Offline
You may not need find at all:
$ for f in *.mp3; do echo $f; done
bar.mp3
baz.mp3If you want to use find, try
$ find * -name "foo.*" -o -name "bar.*"
bar.mp3
bar.mp4
foo.mp4
$ for i in $(find * -name "foo.*" -o -name "bar.*"); do echo "${i[@]/%mp*/ogg}"; done
bar.ogg
bar.ogg
foo.oggI just used 'echo', but you have to use ffmpeg with some options.
Offline
okay, I found this script from : http://stackoverflow.com/questions/5244 … many-files
#!/bin/bash
find . -name "*.m4a" | while read filename;
do
new_filename=$(echo "$filename" | sed "s/^\(.*\)m4a$/\1flac/g");
if [ ! -f "$new_filename" ]
then
ffmpeg -i "$filename" -acodec flac "$new_filename" &
wait $!;
fi
doneso this script converts each m4a into a flac while retaining the basename of the filename and changing the extension
I don't know how to read this but I'll figure it out
Thanks
Last edited by beitme (2013-09-15 01:38:29)
Offline
find . -name '*.mp3' -exec bash -c 'NAME="{}" && ffmpeg "$NAME" "${NAME/.mp3/.ogg}"' \;edit: added double quotes around {} and $NAME incase any paths or filenames have spaces.
Last edited by Trilby (2013-09-15 01:52:58)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
thanks guyz, i'll look into your answers. they seem more concise.
Offline