Wednesday, June 20, 2007

Converting video files into PSP format

I have lot of video files(songs/home videos) in my computer. I was trying to convert them into a format playable in PSP. After lot of failed attempts the following settings worked for me. Note the -sameq option makes the output file large. But I like the fact that the output has almost the same quality as the source. Here is the script I use now to convert the file to PSP format after that you can copy the *.MP4 and *.THM files to the video folder of PSP.


#! /bin/sh


#
# Convert the input video file into a format suitable
# for playing in sony PSP
# Author :
# Date : Wed Jun 20 12:13:28 CDT 2007
#


# Restrictions
# BIT_RATE <= 768 kbps
# Up to 320×240 or up to 368×208
# Up to 30 fps
# H.264 Main Profile up to Level 2.1
# Up to 2 reference frames
# LC AAC audio up to 48kHz (Media Manager uses 128kbps)


CROP=0
OUTPUT_FILE=M4V00001


while getopts i:c:o: opt
do
case "$opt" in
i) INPUT_FILE="$OPTARG";;
c) CROP="$OPTARG";;
o) OUTPUT_FILE="$OPTARG";;
\?) echo "Usage: $0 -i [-c ] [-o put file>]\n"
exit 2;;
esac
done

if [ ! ${INPUT_FILE} ]; then
echo "Usage: $0 -i [-c ] [-o le>]\n"
exit
fi

ffmpeg -i "$INPUT_FILE" -f psp -r 29 -croptop ${CROP} -cropbottom ${CROP} -sameq -b 768 -ar
24000 -ab 64 -s 368x208 ${OUTPUT_FILE}.MP4

ffmpeg -y -i "$1" -f image2 -ss 5 -vframes 1 -s 160x120 -an ${OUTPUT_FILE}.THM

No comments: