See the No Root section.
I use old Android devices as headless, remotely-controlled servers and IP cameras. I don't see anything fits my requirements of being open source, hardware-encoded, and customizable. Beside this is fun and give you total control of your flow. This is adapted from an internal project.
Currently the script is encoding H.264, but you can modify the script to stream H.265 (if your device supports it) by changing video_codec to h265 for scrcpy-server and -f h264 to -f hevc for ffmpeg.
- Termux (or any terminal emulator, or somehow you can run shell scripts and programs)
scrcpy-server.jar: you can download any scrcpy client, grab thescrcpy-serverfile, add.jarto its name, and put it into your phone.ffmpeg. Either static linked binary or downloaded from a package manager (like Termux'spkg)adbclient on the phone- root (optional, see below)
You can use any solution like enabling adb over WiFi and use an on-device adb client to connect to it. There are many guides on how to get adb on your device without root and without using another machine.
Use that adb to run the app_process command.
Killing the dead scrcpy-server can also be done through this local adb.
Feel free to comment below.