AndroidScreenCaster is a live screen casting solution for Android devices, with efficient H.264 and WebM encoding via TCP and UDP. Experience low latency streaming to your browser or server for mobile games, presentations, or any other application where real-time screen mirroring is needed.
As a test automation team leader, we needed to mirror live Android screens to web browsers for functional testing of mobile games. Our first approach, using MJPEG, was inefficient, slow, and produced large files. The second approach, using H.264 and VP8 codecs, was successful but lacked readily available code examples.
This project aims to save you time and provide a clear understanding of live screen casting on Android, with efficient media encoding and low latency.
- Samsung Galaxy S7 edge (Android 6.0)
- FFmpeg installed on the server
-
Run the following command to start FFplay:
ffplay -framerate 60 -i tcp://<your server ip here>:49152?listen
- Enter your remote host address (e.g., IP) in the app.
- Choose H.264 as the format.
- Tap "Start" and perform other tasks, allowing FFmpeg to receive enough media data.
ffplay -framerate 60 -i tcp://<your server ip here>:49152?listen
ffplay -i tcp://<your server ip here>:49152?listen
ffplay -framerate 60 -i udp://@:49152
ffplay -i udp://@:49152
ffmpeg -i udp://@:49152 -framerate 60 -codec:v libx264 -profile:v baseline -preset medium -b:v 250k -maxrate 250k -bufsize 500k -vf scale=-1:360 -an -threads 0 output.mp4
ffmpeg -i output.mp4 -vf "setpts=(1/2)*PTS" fast_output.mp4
ffmpeg -i udp://@:49152 -c:v libvpx -b:v 1M -c:a libvorbis output.webm
- https://android.googlesource.com/platform/cts/+/lollipop-release/tests/tests/media/src/android/media/cts
- https://trac.ffmpeg.org/wiki/StreamingGuide
- https://trac.ffmpeg.org/wiki/Encode/VP8
- https://trac.ffmpeg.org/wiki/Encode/H.264
This project is licensed under the terms of the MIT license.