#!/bin/bash #script name: make_psp_movie.sh if [ $# == 0 ] then echo "Use: make_psp_movie video1 video2 video3 ..." fi #target="/home/inittab/tmp/`echo $LOGNAME`/pspmovies/MP_ROOT/100MNV01" target="/usr/local/media/video/pspmovies/MP_ROOT/100MNV01" mkdir -p "$target" for m in "$@" do echo "-------------------" echo "Start converting $m" echo "-------------------" output="10001" while [ -f "$target/M4V${output}.MP4" ] do let "output += 1" done #generate video #If "-r 29.97" does NOT work try "-r 14.985" aspect=$(( echo scale=4 mplayer -quiet -vo null -ao null -frames 0 -identify "$m" 2>&1 | grep ^VIDEO: | awk '{print $3}' | sed 's/x/\//' ) | bc) case "$aspect" in 1.2222|1.2941|1.3333|1.3474|1.3529|1.3629|1.3636|1.4285|1.4666|1.5000) ratio=4:3 res=320x240 ;; 1.7666|1.7777) ratio=16:9 res=368x208 ;; *) ratio=4:3 res=320x240 ;; esac ffmpeg -i "$m" -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -aspect "${ratio}" -s "${res}" "${target}/M4V${output}.MP4" #generate thumbnail ffmpeg -y -i "$m" -f image2 -ss 5 -vframes 1 -s 160x120 -an "${target}/M4V${output}.THM" #list the files that were just generated ls -l "${target}/M4V${output}.MP4" "${target}/M4V${output}.THM" done echo echo "---------------------------------------------------------------------------" echo "You will find any newly generated PSP videos in:" echo " ${target}" echo echo "Please copy them to your PSP's 'MP_ROOT/100MNV01/' folder." echo echo "Note: if that folder doesn't already exist, just create the folders first." echo "---------------------------------------------------------------------------"