Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Feb 2007 13:51:00 +0000
From:      dgmm <freebsd01@dgmm.net>
To:        freebsd-multimedia@freebsd.org
Subject:   Re: Scripted fade in/out of audio
Message-ID:  <200702031351.02094.freebsd01@dgmm.net>
In-Reply-To: <200701300114.34700.freebsd01@dgmm.net>
References:  <200701300114.34700.freebsd01@dgmm.net>

next in thread | previous in thread | raw e-mail | index | archive | help

On Tuesday 30 January 2007 01:14, dgmm wrote:
> All,
>
> Are there any programs out there which can do fade in and out of audio
> during a copy or encode, under control of a shell script or similar?
>
> I have a large number of short video clips which need to be re-encoded into
> one long stream with a one second fade-in at the start of each clip and a
> one second fade out at the end of each clip.
>
> So far, I've got a script which separates audio and video and creates the
> fade-in/out for the video, re-encodes it and muxes the audio back in.
> (I'm sure the script as is could be improved, advice welcome :-)
>
> Would this be better on another list?  If so, which?

Never mind.  A face to face discussion pointed me at sox which does what I 
want.

(code fragment)

echo "-------------------------------------"
echo " Calculating audio fade positions"
echo "-------------------------------------"
aud_time=`sox $tmpdir/zaudio.mp3 2>&1 -e stat | grep Length | \
   cut -d : -f 2 | cut -f 1 | sed 's/^[ \t]*//'`
echo Audio size in seconds: $aud_time
aud_frames=`sox $tmpdir/zaudio.mp3 2>&1 -e stat | grep Samples | \
   cut -d : -f 2 | cut -f 1 | sed 's/^[ \t]*//'`
echo Audio size in frames:  $aud_frames
frames_per_second=`perl -e "print ($aud_frames / $aud_time)"`
int_time=`perl -e "print int($aud_time)"`
frac_time=`perl -e "print int(($aud_time - int($aud_time)) * 
$frames_per_second)"`
stop_time=${int_time}.${frac_time}
echo "-------------------------------------"
echo " Processing audio fades"
echo "-------------------------------------"
sox $tmpdir/zaudio.mp3 $tmpdir/zaudio1.mp3 fade q 2 $stop_time 1

-- 
Dave



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702031351.02094.freebsd01>