Tuesday, January 17, 2023

My recommended settings for the highest-quality videos on PSP

Everyone knows the resolution of the PSP is 480x272, but did you know the PSP is capable of playing videos in 720x480? That's a higher resolution than what every video encoder uses for their own PSP presets. 720x480 at 2000 kbps is also the quality of purchased PSN standard-definition videos back when they were downloadable. They were playable on PSP and PS3 and looked great. 

While a PSP firmware update would eventually allow us to encode our own videos in 720x480 (and match UMD video quality), there was still the aspect ratio problem: we always had to hit Triangle and select "full screen" if the source material was 16:9 (gets annoying fast), and if the videos were 4:3, we were sort of out of luck.

Well, after nearly two decades, I've finally solved it, so now I can encode in the highest resolution at the proper aspect ratio. Looking through my notes, some guy on Dash Hacks long, long ago already got most of it: 
(re: Constant Quantizer) remember lower numbers = higher picture quality = larger file size. going from 21 to 26 will make the files smaller, but they won't look as good, esp on a TV.

Also all of the CQ profiles tend to get too aggressive on simple scenes so smooth gradients and dark scenes will have visible artifacts on a larger display. It's not bad on the PSP screen, but on a larger screen it can be distracting.

One more tip: If you are doing a 720x480 profile, be sure to turn off autocrop and set AR correction to SAR, otherwise you'll lose the anamorphic benefits and end up with a letterboxed 4x3 video and waste lots of CPU time encoding black bars.

Now having said all that, I do things a little differently myself. I make a HQ encode that will look great on my 60+" tv, one that I can play on PSP, PS3, or PC. I try to avoid any PSP specific optimizations. I can always reduce the PQ and PSP optimize it later if I need to. 

Essentially, I imitate the settings used on the PSN Video store. Start with the MP4 PSP AVC TV profile, set the video encoder to CBR 2000 mb/s AVC, set the audio encoder to AAC-LC ABR 256k, set video cropping to 0 (turn off autocrop) and AR correction to SAR. Disable mpeg2fix. Movies will average 1gig/hour, but they will look excellent over TV out, on a PC/laptop, or PS3 on a big screen.

If I need a PSP only (small screen) version, I'll use the big one as the source, and reduce it to 480x272 using the standard MP4 PSP AVC profile with autocrop and AR correction set to black and mpeg2fix/ghostbusters turned on. If you know you are never going to watch it on anything bigger than a PSP screen you can get really aggressive with the encoder.

Changing SAR was one of the big points (although he didn't say to what...), and disabling B-Pyramid (whatever the hell that is) was the other.

I'm using Megui here, which in some ways isn't as flexible as the older versions of Xvid4PSP, but I'm never going back to that. Even the old (i.e. good) versions of Xvid4PSP seemed bloated and I wasn't able to add in chapter data for my other (non-PSP) encodes without running the finished video through YAMB. 

General tab:

  • Make a new OneClick profile (at the bottom). I named mine "PSP 720x480 at 16:9"
  • Video: load AviSynth script here... more on that later
  • Audio: FFmpeg AAC
    • (Config button) Profile: MPEG-4 LC-AAC 
      • ABR 256k

Advanced Config tab:

  • Encoder settings: Config button
    • Create a new preset (at the bottom). I named mine "PSP 720x480 16:9 Best" 
    • Select PS3 under Target Playback Device.
    • AVC Profile: Main Profile
    • AVC Level: Level 3
    • (Frame-Type tab) B-Pyramid Disabled (Easy to miss and most important! Otherwise the video won't play on a PSP!)
    • (Misc tab) Input/Output: Force SAR: (This is what we're here for: making sure we get 16:9!)
      • 40:33 for 16:9 content
      • 10:11 for 4:3 content
    • Encoding Mode: Automated 2pass / Bitrate: 2000
  • AviSynth settings: CHECK "Keep Input Resolution (disable crop & resize)"

The one drawback to this method is you have to load the clip via AviSynth because Megui doesn't let you change the frame rate. Well, I guess it does, but in a way that's more complicated than just writing your own damn AviSynth script to begin with. The AviSynth script does three things:
  1. Loads any format, no fuss, no muss.
  2. Lets you change the frame rate to 29.97, which is crucial because the PSP can't seem to play videos well at higher framerates, even if you do overclock (to do: try videos at 60 FPS 480x272).
  3. Lets you know for damn sure that you're inputting a 720x480 video, so you can check the "Keep Input Resolution (disable crop & resize)" box with full confidence.
For that first one, we're using the LSMASHSource plugin. Loading scripts with it in VirtualDub might take a while, but it's necessary. Here's the script in full (after I trimmed the fat):

LoadPlugin("C:\Program Files (x86)\AviSynth+\plugins64+\LSMASHSource.dll")

rawfile1v=LWLibavVideoSource("Untitled 05.avi")
rawfile1a=LWLibavAudioSource("Untitled 05.avi")
AudioDubEx(rawfile1v, rawfile1a)
rawfile1=last.BilinearResize(720,480)  

return rawfile1.ChangeFPS(29.970, linear=true)

Easy. 

Other fun links:

Saturday, January 7, 2023

Finding the mythical "compromise crop" between 4:3 and 16:9



I was watching a DuckTales movie from 1990 on Disney+, which was almost certainly originally 4:3, but it was presented in widescreen with thinner-than-usual pillarboxes. So that got me looking for the only good compromise for viewing zoomed-in 4:3 content on a 16:9 display: zooming in just enough to keep the original aspect ratio, but without cropping all the way so as not to lose too much information on the top and bottom of the screen.

This is what I'm talking about: 


The area in green is the full 16:9 1080p image. The area in black is the 4:3 image. The area in red is the left and right sides of the zoomed-in 4:3, with the empty selection on the top and bottom showing what's cropped.

Getting the numbers in GIMP:

1080p is 1920x1080.

4:3 content in a 1080p frame is 1440x1080.

The remaining pillar bars (the green in my illustration) have a width of 240 pixels each.

Half of 240 is 120 (this is the "compromise" part), so in GIMP I had to create a rectangle from the inner columns (the red in my illustration) with the Rectangle Select Tool until it said the rectangle was 1.33:1. (1.33:1 = 4:3). 

The numbers I got were 1680x1260... but I could be off a few pixels. It needs to reduce to exactly 4:3...

1680/420=4

1260/420=3

So yeah, 1680x1260 is what I need for a 4:3 clip before chopping it for the compromise crop.

In practice, what this means starting with a 1080p raw capture, I have to:

  1. Crop from 1920x1080 to 1440x1080 (that is, crop 240 on the left and right) to get a clip that's 4:3.
  2. Resize the clip to 1680x1260. Luckily this is still mod16 for quick, clean, no-fuss resizing with BicubicResize.
  3. Because 1260-1080=180, I need to crop 90 off the top and bottom. Clip so far is 1680x1080.
  4. Because 1920-1680=240, I need to add 120 to the left and right. Clip is now 1920x1080.
In AviSynth: 
.Crop(240,0,-240,0).BicubicResize(1680,1260).Crop(0,90,0,-90).AddBorders(120,0,120,0)

Bonus: Resolution cheat sheet

Thursday, January 5, 2023

2023: A new movie (or similar) every day

Trying this again. Last year I only made it to mid-April I think, but I did catch up on everything MCU at the time.

Will update this post very frequently!

January 2023:

  1. The Incredibles
  2. Strange World
  3. Incredibles 2
  4. Incredibles 2 bonus features (almost two hours, not including the full commentary track!)
  5. Dan in Real Life
  6. DuckTales the Movie: Treasure of the Lost Lamp
  7. Toy Story 2
  8. Toy Story 2 bonus features