PS Vita / Ps TV PSVita USB streaming! (UVC USB Video Class) - v1.1 by Xerpi

STLcardsWS

Administrator

  • PSVita USB streaming! (UVC USB Video Class)

    Since this plugin has been mostly working for quite a while already, I have decided to leave the "Proof-of-concept" stage (PoC) and change it into regular versioning.

    Changes since PoC v6:
    • Fixed right screen margin glitch
    • More general code cleanups and improvements

    If the video looks glitched, try to change the video player configuration to use the NV12 format or switch to another player (like PotPlayer or OBS). If you use Windows 10 you might have to change the Camera access permissions on the Privacy Settings​


    Update v1.1 - Changes since v1.0:

    • Added 896x504 and 480x272 video modes
    • Added 30FPS support
    • VitaShell's USB mode should work (starting at VitaShell 1.95) but a reboot will be needed after disabling USB in order to get this plugin working again
    List of supported video modes:
    • 960x544 @ 30 FPS and (less than) 60 FPS
    • 896x504 @ 30 FPS and (about) 60 FPS
    • 480x272 @ 30 FPS and 60 FPS
    If the video looks glitched, try to change the video player configuration to use the NV12 format or switch to another player (like PotPlayer or OBS). If you use Windows 10 you might have to change the Camera access permissions on the Privacy Settings.​


  • Installation:
    1. Copy udcd_uvc.skprx to your PSVita
    2. Add udcd_uvc.skprx to taiHEN's config (ur0:/tai/config.txt or ux0:/tai/config.txt):
    *KERNEL
    ur0:tai/udcd_uvc.skprx

    3. Reboot your PSVita.

  • Audio noise fix:
    • Disable USB power supply (Settings > System)

  • Source code:

    Important Notes

    • Note: Remember that if anything goes wrong (like PSVita not booting) you can always press L at boot to skip plugin loading.
    • Note 2: No, it doesn't stream audio. For that use a 3.5mm jack to jack adapter (a ferrite bead might help reduce the electromagnetic noise).

  • PoC v6:
    • Fully optimized USB frame transfer function, now the plugin uses almost no CPU, which means less battery usage and more FPS (specially with heavy games)
    • Fixed PS1 video glitch (on Adrenaline)
    • More general code cleanups and improvements
    If the video looks glitched, try to change the video player configuration to use the NV12 format or switch to another player (like PotPlayer or OBS). If you use Windows 10 you might have to change the Camera access permissions on the Privacy Settings.

    PoC v5
    • Use main DRAM instead of CDRAM for the color-space conversion output; now games have more CDRAM available and chances are more of them will boot now
    • Properly handle framebuffers with size different than 960x544 (fixes Adrenaline!)
    • Reduced plugin size
    • General code cleanups and improvements
    If the video looks glitched, try to change the video player configuration to use the NV12 format or switch to another player (like OBS or PotPlayer). If you use Windows 10 you might have to change the Camera access permissions on the Privacy Settings.


    PoC v4
    • Removed slow formats (MJPEG and YUY2)
    • Faster video frame transfer function
    • Reduced memory footprint (more games should boot now)
    • General code cleanups and improvements
    The default video format is now NV12 and thanks to all those changes, it is now able to stream at about 60FPS! If the video looks glitched, try to change the video player configuration to use the NV12 format or switch to another player (like OBS).

    PoC v3
    • Further optimizations to the USB video frame transfer routine.
    • Support for 3 video formats (see below).
    • General code simplifications, improvements and optimizations.
    The supported image/video formats are:
    • MJPEG: See the PoC v2 post for more information.
    • NV12 (fastest): Uses the hardware color-space converter engine.
    • YUY2 (slowest): It performs the color-space conversion by CPU (don't use it).
    The fastest video format is currently NV12, with which it takes around 2ms to perform the color-space conversion and about 18ms to send the frame through USB, this means that almost 50FPS will be achieved. On the other hand, MJPEG encoding is very slow, so I'd advise not using it.
    I have tried to make NV12 the default format, but some webcam/video players will insist to pick another one. If possible, change their configuration to pick NV12 to get the most FPS.


    PoC v2

    • Uses Vita's colorspace conversion hardware
    • Uses Vita's JPEG encoder hardware
    • Much improved and faster USB video frame transfer routine
    After performing some timing to these three key components, the results are the following with a 960x544 framebuffer:
    • It takes around 2ms to perform the colorspace conversion, which is really fast
    • It takes from 86ms to 120ms to perform the JPEG encoding, which is too slow
    • It takes 2ms to send the video frame, which is fast
    If we want to achieve 60FPS, a new frame would need to be ready after 16.667ms, and if you add the worst case time it currently takes (2 + 120 + 2 = 124ms) to process the frame, you'll see that 10FPS are the current expected FPS.
    So this leaves us with the following conclusion: if we want a decent framerate, downscaling to 480x272 is a must. This PoC v2 version I'm releasing doesn't have said downscaling yet, as I'd like to hear your opinions/ideas first.


    PoC v1 - Initial Release
    So this is a project I've had in mind for a few months already and finally I've decided to put some effort into it.
    Let me explain: the Vita OS has a module (SceUdcd) that allows you to setup the Vita (fat and slim) bottom USB port as any USB device by setting custom USB descriptors.
    In the past, I've already used SceUdcd to make the Vita act as an standard USB HID Gamepad (check this) so I asked myself: why don't I take advantage of the power of that module and write a plugin that setups the Vita as an USB Video Class device (like a webcam or USB video capture card) and sends the screen data to the PC?

    And here we are, it has taken me quite a bit of reverse engineering the Vita OS (specially the SceDisplay and SceUdcd modules) to be able to have a very alpha-stage proof of concept skprx working.
    As I said it's very PoC, so don't expect it to go fast at all: the code is currently very inefficient and I'm not taking advantage of the Vita's hardware colorspace converters and image encoders at all, it's all done by CPU. Also, for now, this version will only capture the LiveArea footage.
    Even though it isn't very useful at its current stage, I'm releasing this so you can test it on different OSes and report back whether it's working or not (I'm developing on Linux so that's my testing platform).
    To make it easier to load this plugin I've created a Plugin loader VPK that its job is to load any skprx placed in ux0:data/tai/kplugin.skprx. Here's the download of plugin_loader.vpk.
    And the plugin itself can be found here.

    Hope it works (as much as it can for now) and I'm expecting your feedback!

 

Similar threads

Back
Top