Multiple file conversion with ffmpeg
Page 1 of 1

Author:  Hiperi0n [ Wed Oct 01, 2008 9:05 am ]
Post subject:  Multiple file conversion with ffmpeg

Hi everyone.

I am trying to write a simple script to recode all the .mp3 files in a folder to 160k using ffmpeg. I have one little problem, I would like the output file to be the same as the input file (rewrite) so ffmpeg warns you about this and asks you for confirmation (y/N). Is there a way to automatically "echo a y and an enter" (sorry for the poor explanation) for every question it asks? I have tryied the yes command but it infinitely prints y and the loop won't finish. This is the code I have written so far.

for f in *.mp3; do
   ffmpeg -i $f -ab 160k $f

Is it possible to do something like this:

ffmpeg -i $f -ab 160k $f & echo -e "y \r"

I guess the trick is in the piping/redirection... is the & correct? I know I can avoid this problem simpli not rewriting the original file, but I am curious and would like to enlighten my mind a bit. Thanks. :)

Author:  Daenyth [ Wed Oct 01, 2008 7:59 pm ]
Post subject: 

Use echo y | foo to connect echo's stdout to foo's stdin

Author:  Hiperi0n [ Thu Oct 02, 2008 5:16 am ]
Post subject: 

Thanks Daenyth, I thought that would work, but it does not. ffmpeg stops and only encodes a few kilobytes.

Author:  Hiperi0n [ Thu Oct 02, 2008 5:19 am ]
Post subject: 

Well, it turns out I am a bit stupid :D

If I am overwriting the original mp3 file, there is nowhere to read from to continue the conversion! It is not a BASH problem, it is a basic computing fact...

Thank you :wink:

Author:  jbsnake [ Thu Oct 02, 2008 10:29 am ]
Post subject: 

could do something nice like:
for f in *.mp3; do
   ffmpeg -i "$f" -ab 160k tmp.file
   mv tmp.file "$f"

Author:  fredrik.eriksson [ Tue Nov 18, 2008 10:04 am ]
Post subject: 

You can also use a redirection for this.

for i in *.mp3; do
ffmpeg -i "$f" -ab 160k "$f" <<EOF

Not 100% sure it'll work for ffmpeg thou, but works fine with read :)

Best regards
Fredrik Eriksson

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group •