#!/bin/bash # # Script to convert a dv capture file to a compressed video suitable # for uploading to video sharing web sites. (Rev 10) # # Usage: Takes one parameter - the input dv file (should have .dv extension). # Output is a file with the same base name but a .avi extension. # # Originally by: Sandip Bhattacharya [ lists (at) sandipb . net ] # Note: This script is in the public domain. Suggestions to improve this most # welcome. :) ### EDITABLE CONFIG VALUES #################################################### # The default will convert a 16:9 DV input file to a 4:3 AVI file suitable for # uploading to video sharing sites like Vimeo (http://vimeo.com). You normally # don't need to change anything here. # # However, you can tweak VID_BITRATE up or # down according to the quality/size tradeoff you want. # # Also, if your video is already in 4:3 size or if you want your output to # remain widescreen, set VID_169_TO_43 to 0. ############################################################################## # Audio related AUD_CODEC=mp3 AUD_BITRATE=64k # Video related VID_CODEC=h264 # One of the best video compression codec. Also # Vimeo's recommendation VID_KEYFRAME_FREQ=30 # As per vimeo's recommendation. VID_BITRATE=900k # Video bitrate, higher values give better quality # but larger file size VID_INPUT_INTERLACED=1 # 1, if your input video is interlaced. 0, if not. # Most camcorders have interlaced video. So if you # are not sure, leave this on. VID_169_TO_43=1 # Set to 1 if you want to convert 16:9 to 4:3 VID_LETTERBOX_COLOR="000000" # Color of bars at the top and bottom # When a widescreen input is converted # 000000 = black ffffff=white # Metadata AUTHOR="Sandip Bhattacharya" # Embedded in the video metadata COPYRIGHT="Copyright (c) 2008, Sandip Bhattacharya (lists AT sandipb.net )" COMMENT="Video processed using ffmpeg (http://ffmpeg.mplayerhq.hu/)" # Misc SYS_NUM_THREADS=2 # Number of processing threads. #VERBOSE=1 FFMPEG=/usr/bin/ffmpeg ############################################################################### ### DON'T EDIT ANYTHING BEYOND THIS POINT ##################################### ############################################################################### DEINTERLACE= [ $VID_INPUT_INTERLACED == 1 ] && DEINTERLACE="-deinterlace" SIZECHANGE= [ $VID_169_TO_43 == 1 ] && \ SIZECHANGE="-s 640x360 -padtop 60 -padbottom 60 -padcolor $VID_LETTERBOX_COLOR -aspect 4:3" COPYRIGHT=${COPYRIGHT/ AT /@} [ $# -eq 0 ] && echo "Need the dv file to convert (Syntax: $0 )" && exit 1 INPUT=$1 OUTPUT=${1/.dv/.avi} echo "Converting $INPUT => $OUTPUT" $FFMPEG -threads $SYS_NUM_THREADS \ -f dv \ -i $INPUT \ -vcodec $VID_CODEC \ -g $VID_KEYFRAME_FREQ \ $DEINTERLACE \ -b $VID_BITRATE \ $SIZECHANGE \ -acodec $AUD_CODEC \ -ab $AUD_BITRATE \ -author "$AUTHOR" \ -copyright "$COPYRIGHT" \ -comment "$COMMENT" \ $OUTPUT