vuquangtrong / androidmirrroing

mirror android device to web using h264 stream
GNU General Public License v3.0
55 stars 14 forks source link

The vedio stream can't show rightly #1

Open adfghzhang opened 5 years ago

adfghzhang commented 5 years ago

I run scrcpy and start mirror. When I open the broswer the cavans show me a borken image like the attch file. But I can control the device rightly. Please fix it. wechatimg14

vuquangtrong commented 5 years ago

Hi, the project is at very beginning stage, so I just fixed the size of a frame. please edit the width and height in file mirror.js

ws.send(JSON.stringify({
      action: 'init',
      width: '720',
      height: '1280'
    }));

and in index.html

wsavc.swipe(
            startX * 720 / width,
            startY * 1280 / height, 
            endX * 720 / width, 
            endY * 1280 / height,
            elapsedTime);

Please try and send me your feedback. I will update the code to send the frame size to client soon.

adfghzhang commented 5 years ago

yes, I change the size with my phone. But it still not work. Can you email to me and give me some help. My emil-addr:adfghzhang@live.cn

vuquangtrong commented 5 years ago

What is your phone model and its android version? scrcpy requires android 5.0+ (my old one is 4.3 and scrcpy doesnot work with it)

Could you add console.log() in the http-live-player.js at line 4446?

this.ws.onmessage = (evt) => {
      if(typeof evt.data == "string")
        return this.cmd(JSON.parse(evt.data));

      this.pktnum++;
      var frame = new Uint8Array(evt.data);
      console.log("[Pkt " + this.pktnum + " (" + evt.data.byteLength + " bytes)]");
      console.log(frame);
      //this.decode(frame);
      framesList.push(frame);
    };

Then in browser console, check the frame data which should be start with [0,0,0,1]. One more, please check the port 8091. it maybe blocked.

I have tested with Samsung S7 ( set at 720x1280, 1080x1920, 1440x2560) and Nexus 6P (1440x2560).

powerProgrammerMa commented 5 years ago

image

image

image ![Uploading image.png…]()

powerProgrammerMa commented 5 years ago

image

powerProgrammerMa commented 5 years ago

This mistake occasionally occurs.

adfghzhang commented 5 years ago

My Phone is Honor 7i with Android version 6.0 (1080x1920), RedMe Note4x with Android 6.0 (1080x1920) powerProgrammerMa is my partner

vuquangtrong commented 5 years ago

It seems that the problem comes from Broadway.js which cannot render portrait mode (1080x1920) but can render landscape mode (1920x1080). image

I will check more and if problem is in Broadway.js, we should talk to him.

adfghzhang commented 5 years ago

I test on a genymotion emulator with landscape mode (1280x720), it works right. And I changed it to 720x1280 also work well.

vuquangtrong commented 5 years ago

You should test with Broadway.js or h264-live-player.js on browser. Genymobile's scrcpy emulator does not use JS rendering.

As I tested on browser, only portrait at size of 1080x1920 is not working. Could you make a test with ffmpeg to stream 1080x1920 h264 to a web page? if it also fails, then the problem is from Broadway.js.

wzrf commented 4 years ago

Hi guys, did you figure it out? I'm using 1080 x 1920 device, and it's also not decoding properly.

Snotra-p commented 4 years ago

how can i decode correctly 2220x1080 ? plz help me

krishtoautomate commented 3 years ago

same issue

wj2008 commented 2 years ago

which android version can't decode ? 是不是这个原因 “因为 Broadway 插件不支持 H264 baseline”

MilkFlavor commented 2 years ago

I think I got it. According to the original author of this project, this is a problem with Broadway.js. Apparently, it can only run in landscape mode. So I created a fork fixing these issues, however, the project still doesn't have rotation support. Here is the link: https://github.com/MilkFlavor/androidmirrroing

I'm gonna try adding rotation support, but for now, it only works on landscape mode. One of my solutions is to reduce the resolution of the images or the phone itself.

airhandsome commented 2 years ago

I think I got it. According to the original author of this project, this is a problem with Broadway.js. Apparently, it can only run in landscape mode. So I created a fork fixing these issues, however, the project still doesn't have rotation support. Here is the link: https://github.com/MilkFlavor/androidmirrroing

I'm gonna try adding rotation support, but for now, it only works on landscape mode. One of my solutions is to reduce the resolution of the images or the phone itself.

Hello, I downloaded your project and tried to run it. However nothing is shown in to web. Can you help? My Email Address is: hansen_tear@hotmail.com

MilkFlavor commented 2 years ago

Did you run it with both scripts? You have to run it with scrcpy.bat, then go into the mirroring folder and run npm run start. I find this process kind of tedious so I'll try simplifying it to one command and completely getting rid of the .bat files at a later date. For the time being, you have to give more information about your situation. Also, feel free to create an issue or pull a request on my project.

MilkFlavor commented 2 years ago

I think of manually starting the adb server by running scrcpy.bat it'll be more efficient if we replace that with appium-adb I'm also thinking of compiling the project to web assembly. Apparently, "Wasm is 1.15-1.67 times faster than JavaScript on Google Chrome on a desktop", it shouldn't be that difficult.