[FFmpeg-user] Trouble with ffmpeg in bash script

Georgi Chorbadzhiyski gf at unixsol.org
Fri May 2 17:43:43 CEST 2014


On 02.5.2014 г. 16:13, Cortman wrote:
> I have written a Bash script to recursively convert files of <format> to
> mp3. I originally wrote it using an avconv command, but as I have compiled
> ffmpeg for other purposes on the machine I would like to use ffmpeg in the
> script instead.
>
> Here is the code of my script:
>
> #! /bin/bash
>
> set -e
>
> extension=$1
>
> if [ -z "$1" ] ; then
> echo "You must provide the file extension as an argument"
> fi
>
> files=$(find . -type f -name "*.$extension")
>
> while read -r line ; do
> ffmpeg -i "$line" -c:a libmp3lame -q:a 0 "${line/%$extension/mp3}"
> done <<< "$files"

Always use

ffmpeg .... < /dev/null

in such scripts (loops with stdin input). ffmpeg also tries to read
from stdin and this is where it goes wrong for you.

-- 
Georgi Chorbadzhiyski | http://georgi.unixsol.org/ | http://github.com/gfto/


More information about the ffmpeg-user mailing list