On Sun, 2017-06-25 at 18:30 +0300, Teemu Likonen wrote: > Dominic Knight [2017-06-25 15:35:46+01] wrote: > > > To convert a series of .flac files to .mp3 files I attempted to use > > the > > following line; > > > > > $ find -name "*.flac" -exec bash -c 'ffmpeg -i "{}" -y -acodec > > > > libmp3lame -ab 320k "${0/.flac}.mp3"' {} \; > > The arguments for "bash -c" go like this: > > bash -c '...' name one two three > > And in '...' the arguments are in variables $0 (=name), $1 (=one), $2 > (=two), $3 (=three) etc. So: > > find -name "*.flac" -exec \ > bash -c 'ffmpeg -i file:"$1" -c:a libmp3lame -ab 320k -y > file:"${1%.flac}.mp3"' \ > foo {} \; > Thanks Teemu that works perfectly some nicely converted radio shows now, cheers.
> Note the "foo": it is saved to $0 ("shell's name") and and then the > actual filename is in usual first positional parameter $1. We also > want > to have explicitl "file:" protocol with ffmpeg so that any > "something:" > prerix in filename is not interpreted as a protocol name. (See "man > ffmpeg-protocols".) > I never realised ffmpeg was as capable as that - impressive. > But here's another way without double quoting: > > while read -r -d $'\0' input; do > ffmpeg -i file:"$input" -c:a libmp3lame -ab 320k \ > -y file:"${input%.flac}.mp3" > done < <(find . -name '*.flac' -print0) > This however doesn't work, what this snippet does is write the first 20 seconds of one of the .flacs to an mp3 (this is also the endpoint of the opening jingle and so very short break/space in the track, as produced by audacity - it may work on individual music tracks - not tested that yet) and then goes off into CPU wonderland tying the processors up at 100% until killed. Cheers for the first one though I think I get what is happening in my first attempt now, bash -c $0 always returned the same name to ffmpeg for conversion. Dom.