1#!/bin/bash 2 3if ( test ${#} -lt 1 ) ; then 4cat << !EOF 5usage: $0 "%s" %d %d %d %d %f %d & 6 %s: file name of the frames, e.g. 'cap-%04d.xwd' 7 %d: number of the first saved frame 8 %d: number of the last saved frame 9 %d: width of the frame 10 %d: height of the frame 11 %f: frames per second 12 %d: time per frame (ms, TPF = 1000 / FPS) 13 14!EOF 15exit 16fi 17 18LOC_TRANSCODE=`which transcode` 19LOC_FFMPEG=`which ffmpeg` 20LOC_MENCODER=`which mencoder` 21EXTENSION=`echo "${1}" | nawk -F "." '{print tolower($NF)}'` 22FILE=`echo "${1}" | sed 's/%[\.]*[0-9]*[i|d]/*/g'` 23OUTPUTFILE="/tmp/output.avi" 24 25 26# 27# ffmpeg part 28# 29 30if ( test -z ${LOC_FFMPEG} ) ; then 31 echo "ffmpeg not found, trying transcode ..." 32else 33 if test "x${EXTENSION}" = "xpng" -o "x${EXTENSION}" = "xppm" -o "x${EXTENSION}" = "xpgm" ; then 34 echo "Encoding with ffmpeg found at: ${LOC_FFMPEG}" 35 FFMPEG_FILE=`echo "${1}" | sed 's/%[\.]*/%/g'` 36 37 ${LOC_FFMPEG} -y -r ${6} -i ${FFMPEG_FILE} ${OUTPUTFILE} 38 exit 0 39 else 40 echo "of xvidcap's output files ffmpeg only supports png, ppm, and pnm." 41 echo "can't encode the input files you're providing, sorry." 42 exit 1 43 fi 44fi 45 46 47# 48# transcode part 49# 50 51if ( test -z ${LOC_TRANSCODE} ) ; then 52 echo "transcode not found, trying mencoder ..." 53else 54 echo "Encoding with transcode found at: ${LOC_TRANSCODE}" 55 56 LIST="/tmp/xv_transcode_${$}.piclist" 57 DIM="${4}x${5}" 58 FPS="${6}" 59 ls -1 ${FILE} | sort > ${LIST} 60 ${LOC_TRANSCODE} -i ${LIST} -g ${DIM} -x imlist,null -y ffmpeg,null -F mpeg4 -f ${FPS} -o ${OUTPUTFILE} -H 1 --use_rgb 61 rm ${LIST} 62 exit 0 63fi 64 65 66# 67# mencoder part 68# 69 70if ( test -z ${LOC_MENCODER} ) ; then 71 echo "mencoder not found either, sorry!" 72else 73 if test "x${EXTENSION}" = "xpng" -o "x${EXTENSION}" = "xjpg" -o x"${EXTENSION}" = "xjpeg" ; then 74 echo "Encoding with mencoder found at: ${LOC_MENCODER}" 75 76 ${LOC_MENCODER} "mf://${FILE}" -mf fps=${6} -o ${OUTPUTFILE} -ovc lavc 77 else 78 echo "of xvidcap's output files mencoder only supports png and jpg." 79 echo "can't encode the input files you're providing, sorry." 80 fi 81fi 82 83exit 84