GithubHelp home page GithubHelp logo

magicsih / androidscreencaster Goto Github PK

View Code? Open in Web Editor NEW
191.0 17.0 70.0 211 KB

Efficient, low-latency Android screen casting with H.264 and WebM encoding via TCP and UDP.

License: MIT License

Java 100.00%
android screensharing screenshot screencast mirroring h264 avc vp8 webm udp

androidscreencaster's Introduction

Android Screen Caster - Low Latency Screen Mirroring

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.

Motivation

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.

DEMO

Demo

Tested Device

  • Samsung Galaxy S7 edge (Android 6.0)

Requirements

  • FFmpeg installed on the server

Screenshots

Screenshot

Quick Start

Server-side

  • Run the following command to start FFplay:

    ffplay -framerate 60 -i tcp://<your server ip here>:49152?listen

Client-side (Android App)

  1. Enter your remote host address (e.g., IP) in the app.
  2. Choose H.264 as the format.
  3. Tap "Start" and perform other tasks, allowing FFmpeg to receive enough media data.

FFmpeg Commands for Server-side

PLAY

TCP+H264

ffplay -framerate 60 -i tcp://<your server ip here>:49152?listen

TCP+VP8

ffplay -i tcp://<your server ip here>:49152?listen

UDP+H264

ffplay -framerate 60 -i udp://@:49152

UDP+VP8

ffplay -i udp://@:49152

RECORD

UDP+H264

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

To increase playback speed, re-encode output.mp4:

ffmpeg -i output.mp4 -vf "setpts=(1/2)*PTS" fast_output.mp4

UDP+VP8

ffmpeg -i udp://@:49152 -c:v libvpx -b:v 1M -c:a libvorbis output.webm

Reference

License (MIT)

This project is licensed under the terms of the MIT license.

androidscreencaster's People

Contributors

magicsih avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidscreencaster's Issues

help

please code server socket java decode h264 and play stream

Android x86 and VP8 doesn't work

Hi!,

I like your app, it works fine with my device, but I was trying to mirror my Android-x86 testing environment and with H264 seems to work but with VP8 it doesn't. There are no errors in Android but ffplay cannot decode, this message appears: "nvalid data found when processing input".

Do you know if I must change something in the encoding configuration when it runs in Android-x86?, or why h264 works fine but vp8 no (both tcp/udp)?

Captura de pantalla de 2020-09-25 12-30-47

LICENSE

Great project!

Does this project have OSS LICENSE?

casting android screen only shows the first couple frames

Hello developer,

I'm trying to use your codes for one of our application in which we deploy your application on an Android Virtual Machine and trying to cast any application on the Virtual Machine remotely on a remote PC.
The whole application is kind of working; however, it is casting/displaying only the first couple of frames (h264 format) on the remote PC over the tcp network, then it hang up. We have been debugging for the last couple days without any luck.
Since you are the developer of these codes, can you provide me some helpful information where I can focus and fix this issue.
Very appreciate if you could help me on this issue.

Thanks

Tom

Dcode error on Android device with MediaCodec

I try to decode the H.264 on another Android-device with MediaCodec and display on a SurfaceTexture.
Here are my codes on the server:
Init the Decoder:
image
Decode a frame:
image

The decoded result displayed on the SurfaceTexture:
The first frame is normal
image
But when I do some operations on the client ,It comes out like that:
image

I'm so sorry to bother you again! could you give me some advice.

Send sound from microphone

Hello,
Can you help me ? How can stream sound from microphone? I want stream screen and microphone audio and send to rmtp server using ffmpeg.

Please help me.

Help: How to manipulate display video

For example, I want to rotate the output screen or make the output screen grayscale. How should I do it?
I saw on the back service, there is only an encoder, and the byte array from outputbuffer is not an image format. Can you point me to the right direction.
Thanks for your time!

udp can't work

i use tcp is success,but use udp can't work! anyone have this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.