How to improve Touhou streaming video quality

TL;DR at bottom

Occasionally when watching Touhou games being streamed in Twitch, I've noticed the video stream being quite blurry. A brute force way to approaching the alleviation of this would be to simply increase the bitrate of the stream, but that has various implications and limiters, such as your and the viewers' internet connection speed and bandwidth limits. An alternative approach to this problem is to utilize the currently available bitrate and bandwidth more efficiently. This can be achieved with some tweaking of the settings in Open Broadcaster Software.

1. Lower your resolution

The majority of the Windows Touhou games run at a native resolution of 640x480. That means if you stream them at 1280x720, you're wasting CPU power and processing time on a whole lot of nothing. Instead of making your CPU encode stuff at 720p/1080p/whatever, use the native resolution of the game and move on to step two.

The native resolutions of non-decimal (and non-Phantasmagoria for now since I haven't played them) Windows games:

EoSD640x480
IN640x480
PCB640x480
MoF640x480
SA640x480
UFO640x480
TD640x480
DDC640x480, 960x720 or 1280x960
LoLK640x480, 960x720 or 1280x960

Starting from Double Dealing Character, the games have had options for higher resolutions. You might have to use a faster x264 CPU preset for higher resolutions, since they are more CPU intensive due to simply having more pixels on screen. If you play at 1280x960 but your CPU can't handle encoding it in real time, you can set up a resolution downscale in OBS. This way we can capture the game at it's native resolution, but output a video stream with smaller dimensions. Settings -> Settings -> Video Resolution Downscale. As high as possible is preferable, and the filter settings should be self-explanatory with the part in parentheses.

If you're playing the older Windows games at higher resolutions with vpatch or similar tools, it does not mean the quality of the game improves. They still have 640x480 pixels worth of detail. Video encoders cannot magically draw more content and detail to source footage.

2. Use slower x264 presets

Located at Settings -> Settings -> Advanced -> x264 CPU Preset. Set this to as low as possible. The limit is your CPU getting saturated, or reaching 90-100% utilization. Set this to for example medium for starters, and do a test stream/recording. If the CPU usage is near top, set the x264 CPU preset to a faster one. If the CPU usage is quite low (like 10-30%), set it to slow or slower.

Touhou games, being 2D shmups, are generally not very CPU intensive. This frees up CPU cycles to use in video encoding. By using a slower setting, x264 works harder on producing good quality video. If you have two separate videos at the exact same bitrate, generally speaking the one encoded with a slower setting would look better.

Caveat emptor: for the CPU presets in the slower end, you need a beefy CPU. More cores and hyperthreading never hurts when it comes to video encoding. The best reasonable options would be an i7 or a Xeon E3, being quad core processors with hyperthreading. I don't know how AMD rolls. Their octacores might be nice.

One way to make the encoding easier on the CPU is to stream at 30 fps instead of 60 fps. You can find this setting at Settings -> Settings -> Video -> FPS. This would make the video stream less smooth though.

3. Optional step: tune touhou

Settings -> Settings -> Advanced -> tick Custom x264 Encoder Settings. In the text box, type:

--tune touhou

This is an actually inbuilt, albeit undocumented, setting in x264, the encoding software embedded into Open Broadcaster Software. Without getting too technical about it, the setting allocates the available bitrate differently into different portions of the video. This is helpful due to video encoding and bitrate being a zero-sum game: bitrate spent on less visible and important stuff is bitrate not spent on vital parts, like clear bullet borders.

Disclaimer: I'm not sure about the specifics about this one either. Try it out and see if it's beneficial.

A personal example

If I wanted to stream Imperishable Night, I'd use the following settings in OBS:

Miscellaneous tips

TL;DR