From owner-freebsd-multimedia@FreeBSD.ORG Sat Feb 3 13:51:06 2007 Return-Path: X-Original-To: freebsd-multimedia@freebsd.org Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5354316A406 for ; Sat, 3 Feb 2007 13:51:06 +0000 (UTC) (envelope-from freebsd01@dgmm.net) Received: from lon-mail-1.gradwell.net (lon-mail-1.gradwell.net [193.111.201.125]) by mx1.freebsd.org (Postfix) with ESMTP id C765113C4A6 for ; Sat, 3 Feb 2007 13:51:05 +0000 (UTC) (envelope-from freebsd01@dgmm.net) Received: from lon-mail-1.gradwell.net ([193.111.201.125] helo=webmaker country=GB ident=dave$pop3&dgmm#net) by lon-mail-1.gradwell.net with esmtpa (Gradwell gwh-smtpd 1.243) id 45c49346.12f00.c99 for freebsd-multimedia@freebsd.org; Sat, 3 Feb 2007 13:51:02 +0000 (envelope-sender ) From: dgmm To: freebsd-multimedia@freebsd.org Date: Sat, 3 Feb 2007 13:51:00 +0000 User-Agent: KMail/1.9.1 References: <200701300114.34700.freebsd01@dgmm.net> In-Reply-To: <200701300114.34700.freebsd01@dgmm.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200702031351.02094.freebsd01@dgmm.net> Subject: Re: Scripted fade in/out of audio X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Feb 2007 13:51:06 -0000 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