Code Monkey home page Code Monkey logo

Comments (12)

1bharath-yadav avatar 1bharath-yadav commented on June 5, 2024 1

love your work

from scrcpy.

rom1v avatar rom1v commented on June 5, 2024

The encoder failed. I'm surprised that it does not retry with a lower resolution. Does it only happen with camera capture?

Can you try with -m1024?

from scrcpy.

1bharath-yadav avatar 1bharath-yadav commented on June 5, 2024

Yea

from scrcpy.

1bharath-yadav avatar 1bharath-yadav commented on June 5, 2024

sorry I am an Idoit
it works

scrcpy -m 1024 --video-source=camera --no-audio --camera-facing=front \
    --v4l2-sink=/dev/video0

scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: Video orientation is locked for v4l2 sink. See --lock-video-orientation.
INFO: Camera video source: control disabled
INFO: ADB device found:
INFO:     -->   (usb)  Q8JR4DUCLJIRKVPZ                device  2201117PI
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 115.2 MB/s (69007 bytes in 0.001s)
[server] INFO: Device: [Xiaomi] POCO 2201117PI (Android 13)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 24.0.7-arch1.3
INFO: Trilinear filtering enabled
[server] INFO: Using camera '1'
INFO: v4l2 sink started to device: /dev/video0
INFO: Texture: 960x720
WARN: Killing the server...

from scrcpy.

rom1v avatar rom1v commented on June 5, 2024

scrcpy -m 1024 --video-source=camera --no-audio --camera-facing=front --v4l2-sink=/dev/video0

Does it work if you don't pass --no-audio? Does it work if you don't pass -m 1024?

It should have retried with a lower resolution automatically.

To investigate, could you please test with this server binary where I added some logs:

  • scrcpy-server SHA-256: 7e2f156508386b809abbd47362fef835724e78b8fc8d0911b8f67f9537c651a

And reproduce the error:

export SCRCPY_SERVER_PATH=/path/to/this/scrcpy-server  # adapt the path
scrcpy --video-source=camera --camera-facing=front

Then post the console output.

Thank you

diff
diff --git a/server/src/main/java/com/genymobile/scrcpy/SurfaceEncoder.java b/server/src/main/java/com/genymobile/scrcpy/SurfaceEncoder.java
index 28435c098..9d11e86c3 100644
--- a/server/src/main/java/com/genymobile/scrcpy/SurfaceEncoder.java
+++ b/server/src/main/java/com/genymobile/scrcpy/SurfaceEncoder.java
@@ -61,6 +61,7 @@ public class SurfaceEncoder implements AsyncProcessor {
 
             do {
                 Size size = capture.getSize();
+                Ln.i("==== " + size);
                 format.setInteger(MediaFormat.KEY_WIDTH, size.getWidth());
                 format.setInteger(MediaFormat.KEY_HEIGHT, size.getHeight());
 
@@ -97,6 +98,9 @@ public class SurfaceEncoder implements AsyncProcessor {
     }
 
     private boolean prepareRetry(Size currentSize) {
+        Ln.i("==== firstFrameSend=" + firstFrameSent);
+        Ln.i("==== consecutiveErrors=" + consecutiveErrors);
+        Ln.i("==== downsizeOnError=" + downsizeOnError);
         if (firstFrameSent) {
             ++consecutiveErrors;
             if (consecutiveErrors >= MAX_CONSECUTIVE_ERRORS) {
@@ -117,12 +121,14 @@ public class SurfaceEncoder implements AsyncProcessor {
         // Downsizing on error is only enabled if an encoding failure occurs before the first frame (downsizing later could be surprising)
 
         int newMaxSize = chooseMaxSizeFallback(currentSize);
+        Ln.i("maxSizeFallback index=" + newMaxSize);
         if (newMaxSize == 0) {
             // Must definitively fail
             return false;
         }
 
         boolean accepted = capture.setMaxSize(newMaxSize);
+        Ln.i("fallback accepted=" + accepted);
         if (!accepted) {
             return false;
         }

from scrcpy.

1bharath-yadav avatar 1bharath-yadav commented on June 5, 2024
 scrcpy -m 1024 --video-source=camera  --no-video-playback  --camera-facing=front \
    --v4l2-sink=/dev/video0

scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: Video orientation is locked for v4l2 sink. See --lock-video-orientation.
INFO: Camera video source: control disabled
INFO: Camera video source: microphone audio source selected
INFO: ADB device found:
INFO:     -->   (usb)  Q8JR4DUCLJIRKVPZ                device  2201117PI
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 72.4 MB/s (69007 bytes in 0.001s)
[server] INFO: Device: [Xiaomi] POCO 2201117PI (Android 13)
[server] INFO: Using camera '1'
INFO: v4l2 sink started to device: /dev/video0
scrcpy --video-source=camera --camera-facing=front \
    --v4l2-sink=/dev/video0
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: Video orientation is locked for v4l2 sink. See --lock-video-orientation.
INFO: Camera video source: control disabled
INFO: Camera video source: microphone audio source selected
INFO: ADB device found:
INFO:     -->   (usb)  Q8JR4DUCLJIRKVPZ                device  2201117PI
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 63.4 MB/s (69007 bytes in 0.001s)
[server] INFO: Device: [Xiaomi] POCO 2201117PI (Android 13)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 24.0.7-arch1.3
INFO: Trilinear filtering enabled
[server] INFO: Using camera '1'
INFO: v4l2 sink started to device: /dev/video0
INFO: Texture: 2320x1744
[server] ERROR: Encoding error: java.lang.IllegalArgumentException: null
WARN: Device disconnected
[server] ERROR: Exception on thread Thread[video,5,main]
java.lang.IllegalArgumentException
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:2214)
        at android.media.MediaCodec.configure(MediaCodec.java:2130)
        at com.genymobile.scrcpy.SurfaceEncoder.streamScreen(SurfaceEncoder.java:69)
        at com.genymobile.scrcpy.SurfaceEncoder.lambda$start$0$com-genymobile-scrcpy-SurfaceEncoder(SurfaceEncoder.java:253)
        at com.genymobile.scrcpy.SurfaceEncoder$$ExternalSyntheticLambda0.run(Unknown Source:4)
        at java.lang.Thread.run(Thread.java:1012)

i dont know how to test server

from scrcpy.

rom1v avatar rom1v commented on June 5, 2024

i dont know how to test server

Download the scrcpy-server binary I linked in #4921 (comment).

Then set an environment variable to force scrcpy to use this specific one (adapt the path):

export SCRCPY_SERVER_PATH=/path/to/this/scrcpy-server

Just after, in the same terminal, execute:

scrcpy --video-source=camera --camera-facing=front

from scrcpy.

1bharath-yadav avatar 1bharath-yadav commented on June 5, 2024

from scrcpy.

1bharath-yadav avatar 1bharath-yadav commented on June 5, 2024
$ scrcpy --video-source=camera --camera-facing=front
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: Camera video source: control disabled
INFO: Camera video source: microphone audio source selected
INFO: ADB device found:
INFO:     -->   (usb)  Q8JR4DUCLJIRKVPZ                device  2201117PI
/home/Archer/Desktop/scrcpy-server: 1 file pushed, 0 skipped. 135.3 MB/s (109486 bytes in 0.001s)
[server] INFO: Device: [Xiaomi] POCO 2201117PI (Android 13)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 24.0.7-arch1.3
INFO: Trilinear filtering enabled
[server] INFO: Using camera '1'
[server] INFO: ==== Size{width=2320, height=1744}
INFO: Texture: 2320x1744
[server] ERROR: Encoding error: java.lang.IllegalArgumentException: null
[server] INFO: ==== firstFrameSend=false
[server] INFO: ==== consecutiveErrors=0
[server] INFO: ==== downsizeOnError=true
[server] INFO: maxSizeFallback index=1920
[server] INFO: fallback accepted=true
[server] INFO: Retrying with -m1920...
[server] INFO: Retrying...
[server] INFO: ==== Size{width=1920, height=1440}
INFO: Texture: 1920x1440

from scrcpy.

rom1v avatar rom1v commented on June 5, 2024

Hmm, that's great, but now it retries 🤔

[server] INFO: Retrying with -m1920...

The initial issue was that it did not retry, so I added logs to understand why 😕

Could you reproduce your initial issue (somehow) with this new server binary?

from scrcpy.

1bharath-yadav avatar 1bharath-yadav commented on June 5, 2024
scrcpy --video-source=camera --no-audio --camera-facing=front \
    --v4l2-sink=/dev/video0

scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: Video orientation is locked for v4l2 sink. See --lock-video-orientation.
INFO: Camera video source: control disabled
INFO: ADB device found:
INFO:     -->   (usb)  Q8JR4DUCLJIRKVPZ                device  2201117PI
/home/Archer/Desktop/scrcpy-server: 1 file pushed, 0 skipped. 162.4 MB/s (109486 bytes in 0.001s)
[server] INFO: Device: [Xiaomi] POCO 2201117PI (Android 13)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 24.0.7-arch1.3
INFO: Trilinear filtering enabled
[server] INFO: Using camera '1'
[server] INFO: ==== Size{width=2320, height=1744}
INFO: v4l2 sink started to device: /dev/video0
INFO: Texture: 2320x1744
[server] ERROR: Encoding error: java.lang.IllegalArgumentException: null
[server] INFO: ==== firstFrameSend=false
[server] INFO: ==== consecutiveErrors=0
[server] INFO: ==== downsizeOnError=false
WARN: Device disconnected
[server] ERROR: Exception on thread Thread[video,5,main]
java.lang.IllegalArgumentException
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:2214)
        at android.media.MediaCodec.configure(MediaCodec.java:2130)
        at com.genymobile.scrcpy.SurfaceEncoder.streamScreen(SurfaceEncoder.java:70)
        at com.genymobile.scrcpy.SurfaceEncoder.lambda$start$0$com-genymobile-scrcpy-SurfaceEncoder(SurfaceEncoder.java:259)
        at com.genymobile.scrcpy.SurfaceEncoder$$ExternalSyntheticLambda0.run(Unknown Source:4)
        at java.lang.Thread.run(Thread.java:1012)

from scrcpy.

rom1v avatar rom1v commented on June 5, 2024

Oh, ok, thank you very much! I understand now.

When V4L2 sink is set, the "downsize on error" feature is disabled:

scrcpy/app/src/cli.c

Lines 2571 to 2574 in 206809a

// V4L2 could not handle size change.
// Do not log because downsizing on error is the default behavior,
// not an explicit request from the user.
opts->downsize_on_error = false;

from scrcpy.

Related Issues (20)

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.