Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
111.04k stars 10.64k forks source link

How to get video stream over USB? Not use tcp #3896

Open tiennguyen12g opened 1 year ago

tiennguyen12g commented 1 year ago

Hello everyone, I want to get video stream and use in electron app. Now I use tcp:1234 for getting video stream data from device.

adb push scrcpy-server-v1.25 /data/local/tmp/scrcpy-server.jar
adb forward tcp:1234 localabstract:scrcpy
adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar \
    app_process / com.genymobile.scrcpy.Server 1.25 \
    tunnel_forward=true control=false cleanup=false \
    max_size=1600 raw_video_stream=true

But i get slow when display on app. When I use Scrcpy, it displays good because it connect and stream data via USB. Question:

  1. How can i get video stream via USB without TCP port. ?
  2. When use tcp, i have to build a Node server to listen data from TCP:1234 and emit to app. How can i get video stream data with current Adb server in pc? Thank all you.
rom1v commented 1 year ago

But i get slow when display on app. When I use Scrcpy, it displays good because it connect and stream data via USB.

How is it slow? A high latency? A low frame rate?

How do you display the video stream on your app?

tiennguyen12g commented 1 year ago

How is it slow? A high latency? A low frame rate?<

When i connect and use it, it is a little latency ( less than 1 second). But when i switched to using other app or browser and then back to using it, the delay is a lot ( more than 30s). The window use Scrcpy is still good in display.

How do you display the video stream on your app?<

I do three command above and create a Node server that listen the data stream with port tcp:1234 from android device. The server create a websocket that emit data. I use h264-live-player decode the data stream and display on canvas in html. If you need a video, i will show it. Thank bro.

rom1v commented 1 year ago

I use h264-live-player

It probably buffers frames, which adds latency.