Date: Tue, 30 Jan 2007 01:14:32 +0000 From: dgmm <freebsd01@dgmm.net> To: freebsd-multimedia@freebsd.org Subject: Scripted fade in/out of audio Message-ID: <200701300114.34700.freebsd01@dgmm.net>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701300114.34700.freebsd01>