Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #182659

Re: off topic! What is the error in this script

From Dominic Knight <dominicknight@gmx.com>
Newsgroups linux.debian.user
Subject Re: off topic! What is the error in this script
Date 2017-06-26 03:10 +0200
Message-ID <tWqHo-40n-5@gated-at.bofh.it> (permalink)
References <tWhNL-6OK-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

off topic! What is the error in this script Dominic Knight <dominicknight@gmx.com> - 2017-06-25 17:00 +0200
  Re: off topic! What is the error in this script Wellington Terumi Uemura <wellingtonuemura@gmail.com> - 2017-06-25 17:10 +0200
  Re: off topic! What is the error in this script Teemu Likonen <tlikonen@iki.fi> - 2017-06-25 17:40 +0200
    Re: off topic! What is the error in this script Dominic Knight <dominicknight@gmx.com> - 2017-06-26 03:10 +0200
    Re: off topic! What is the error in this script Greg Wooledge <wooledg@eeg.ccf.org> - 2017-06-26 15:30 +0200
      Re: off topic! What is the error in this script David Wright <deblis@lionunicorn.co.uk> - 2017-06-26 18:40 +0200

csiph-web