I’ll keep this post simple as I don’t fully understand all of the different flags, however I did thoroughly go through various other posts on the x264 codec and the best flags to use for encoding for PSP.

The results below are designed for creating videos at full 720×480 resolution for the PSP with high quality and not super fast encoding in mind. See my earlier post on Encoding video for the PSP for info on alternative methods.

I used a 2-pass encode, but you can use 1-pass if you don’t feel the need, just remove the “-pass 2” code.

ffmpeg -y -i %1 -s 720x480 -r 25 -an -pass 1 -vcodec libx264 -b 1400kb -bt 2000kb -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -refs 2 -me_method umh -me_range 17 -subq 1 -trellis 0 -coder 1 -bf 7 -b_strategy 1 -threads 0 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 %2.mp4

Use the above for the first pass, and the below for the second pass:

ffmpeg -y -i %1 -s 720x480 -r 25 -acodec libfaac -ab 160k -ar 48000 -pass 2 -vcodec libx264 -b 1400kb -bt 2000kb -flags +loop -flags2 +mixed_refs+wpred-fastpskip -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -level 30 -refs 2 -me_method umh -me_range 17 -subq 7 -trellis 2 -coder 1 -bf 7 -b_strategy 1 -threads 0 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 %2.mp4

Note: The “-y” option will automatically overwrite the output file if it uses an existing file name, so remove that if you want to be warned about this by ffmpeg. “-y” forces “yes” as an answer.

I wrote a basic .bat batch script for ms-dos/windows automating this a bit, so you only have to type “ffmpegdos input.file output.name”, these are represented by %1 and %2 respectively in the above ffmpeg examples. You can replace %1 with the actual input file name, and %2 with the actual output filename if you want to just run it manually.

The contents of the .bat file are as follows:

@ECHO OFF
echo about to begin encode process...
pause

echo are you sure you wish to overwrite %2.mp4?
pause
D:InstallFFMpegffmpeg -y -i %1 -s 720x480 -r 25 -an -pass 1 -vcodec libx264 -b 1400kb -bt 2000kb -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -refs 2 -me_method umh -me_range 17 -subq 1 -trellis 0 -coder 1 -bf 7 -b_strategy 1 -threads 0 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 %2.mp4
D:InstallFFMpegffmpeg -y -i %1 -s 720x480 -r 25 -acodec libfaac -ab 160k -ar 48000 -pass 2 -vcodec libx264 -b 1400kb -bt 2000kb -flags +loop -flags2 +mixed_refs+wpred-fastpskip -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -level 30 -refs 2 -me_method umh -me_range 17 -subq 7 -trellis 2 -coder 1 -bf 7 -b_strategy 1 -threads 0 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 %2.mp4
echo DONE!

Just copy paste the above into an empty text file using notepad or similar and save it as ffmpegdos.bat, to run it just open a “Command Prompt” and type ffmpegdos input.file output.name. The .mp4 extension is automatically appended to your output filename.

Good luck!