#!/bin/bash
# Install mencoder & gpac first
# sudo apt-get install mencoder gpac
# Movie file extension definition
extension="rmvb"
for movie in $(ls *.${extension})
do
movie=${movie%.*}
if [ -f "${movie}.mp4" ]; then
echo "$movie.$extension has been converted, ignore..."
else
echo "convert $movie.$extension to mp4..."
mencoder "$movie.$extension" -sws 9 -af volnorm -srate 48000 -vf-add scale=362:272,harddup -ofps 24000/1001 -oac faac -faacopts br=96:mpeg=4:object=2 -ovc x264 -ffourcc H264 -x264encopts crf=22:level_idc=21:bframes=3:frameref=2:nopsnr:nossim -o "${movie}.temp.avi" >& /dev/null
mencoder -ovc copy -nosound -of rawvideo -o "${movie}.temp.264" "${movie}.temp.avi"
mencoder -ovc frameno -oac copy -of rawaudio -o "${movie}.temp.aac" "${movie}.temp.avi"
MP4Box -fps 23.976 -add "${movie}.temp.264"#video -add "${movie}.temp.aac"#audio -new "${movie}.mp4"
rm -f "${movie}.temp.avi"
rm -f "${movie}.temp.264"
rm -f "${movie}.temp.aac"
fi
done
# Install mencoder & gpac first
# sudo apt-get install mencoder gpac
# Movie file extension definition
extension="rmvb"
for movie in $(ls *.${extension})
do
movie=${movie%.*}
if [ -f "${movie}.mp4" ]; then
echo "$movie.$extension has been converted, ignore..."
else
echo "convert $movie.$extension to mp4..."
mencoder "$movie.$extension" -sws 9 -af volnorm -srate 48000 -vf-add scale=362:272,harddup -ofps 24000/1001 -oac faac -faacopts br=96:mpeg=4:object=2 -ovc x264 -ffourcc H264 -x264encopts crf=22:level_idc=21:bframes=3:frameref=2:nopsnr:nossim -o "${movie}.temp.avi" >& /dev/null
mencoder -ovc copy -nosound -of rawvideo -o "${movie}.temp.264" "${movie}.temp.avi"
mencoder -ovc frameno -oac copy -of rawaudio -o "${movie}.temp.aac" "${movie}.temp.avi"
MP4Box -fps 23.976 -add "${movie}.temp.264"#video -add "${movie}.temp.aac"#audio -new "${movie}.mp4"
rm -f "${movie}.temp.avi"
rm -f "${movie}.temp.264"
rm -f "${movie}.temp.aac"
fi
done
从这个脚本可以看到,直接使用mencoder生成MP4是有问题的,因为mencoder对MP4的封装有问题,PSP无法识别,所以后来要用MP4Box重新封装MP4文件。