From owner-freebsd-multimedia@FreeBSD.ORG Tue Jan 30 01:55:26 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 4E74016A402 for ; Tue, 30 Jan 2007 01:55:26 +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 A9A3D13C478 for ; Tue, 30 Jan 2007 01:55:25 +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 45be9c03.12eec.c8 for freebsd-multimedia@freebsd.org; Tue, 30 Jan 2007 01:14:43 +0000 (envelope-sender ) From: dgmm To: freebsd-multimedia@freebsd.org Date: Tue, 30 Jan 2007 01:14:32 +0000 User-Agent: KMail/1.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200701300114.34700.freebsd01@dgmm.net> Subject: 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: Tue, 30 Jan 2007 01:55:26 -0000 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? #! /bin/sh # fader 0.1 - 29/01/07 - Dave Gallagher # Auto add 1sec fade-in/fade-out to avi clips # No error checking, files hard coded while testing clip="/home3/billsvids/MaxQuality/CanadaEdits/101Greenland.avi" pictype=png frames=`tcprobe -i "${clip}" | grep V: | sed -e 's/\[avi.*es=//' -e 's/,.*//'` vbitrate=`mplayer -identify -frames 0 "${clip}" |\ grep ID_VIDEO_BITRATE |\ sed -e 's/.*RATE=//'` vbitrate=$(($vbitrate / 1000)) echo Frames="${frames}" echo Video Bitrate="${vbitrate}kbps" echo "------------------------------" echo " Extracting audio" echo "------------------------------" mplayer -msglevel all=-1 -benchmark -vc null -vo null -dumpaudio \ -dumpfile zaudio.mp3 "${clip}" echo "---------------------------------------" echo " extract frames" echo "---------------------------------------" if [ $pictype = jpg ] ; then echo Doing JPeG ; ptype="jpeg:quality=100" else echo Doing PNG ; ptype="png:z=0" fi mplayer -benchmark -nosound -vo "${ptype}" "${clip}" #process frames to fade up from 0% brightness to normal count=1 while [ $count -le 25 ] ; do sframe=`echo $count | awk '{printf("%8d",$0)}' | sed 's/ /0/g'`.${pictype} fadein=$(($count * 4)) #Might as well count backwards from the end too and fade out end=$(($frames - $count)) eframe=`echo $end | awk '{printf("%8d",$0)}' | sed 's/ /0/g'`.${pictype} echo $sframe $eframe $fadein mogrify $sframe -modulate $fadein $sframe mogrify $eframe -modulate $fadein $eframe count=$(($count + 1)) done # VERY HIGH QUALITY video="-ovc lavc -lavcopts vcodec=mpeg4:mbd=2:mv0:\ trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=2:\ vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:qns=2" # VERY FAST video="-ovc lavc -lavcopts vcodec=mpeg4:mbd=2" bitrate="vbitrate=1200" for j in "turbo:vpass=1 -nosound" "vpass=2 ${audio}" ; do mencoder -force-avi-aspect 4:3 -oac copy -audiofile zaudio.mp3 \ -mf fps=25:type=$pictype "mf://*.$pictype" \ ${video}:${bitrate}:${j} -ffourcc DX50 -o z1video.avi done if [ $pictype = jpg ] ; then rm *.jpg else rm *.png fi rm zaudio.mp3 mplayer z1video.avi -- Dave