Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrcpy is lagging for no reason #4494

Closed
tanzz107 opened this issue Dec 3, 2023 · 24 comments
Closed

Scrcpy is lagging for no reason #4494

tanzz107 opened this issue Dec 3, 2023 · 24 comments

Comments

@tanzz107
Copy link

tanzz107 commented Dec 3, 2023

my phones lcd just came out of the phone a day ago and i tried to use scrcpy but it just lags all the time and takes about 30 secs to respond, my pc is way too powerful for that to happen, ive been trying my best to use tricks from youtube and they still give me the same result. This is what its saying:
(usb) 4bdba881 device 11R
C:\scrcpy-win64-v2.3.1\scrcpy-server: 1 file pushed, 0 skipped. 106.9 MB/s (66007 bytes in 0.001s)
[server] INFO: Device: [OnePlus] OnePlus 11R (Android 12)
INFO: Renderer: direct3d
INFO: Texture: 1080x2400

@rom1v
Copy link
Collaborator

rom1v commented Dec 3, 2023

Is it better with a lower resolution:

scrcpy -m1024

?

@rom1v
Copy link
Collaborator

rom1v commented Dec 3, 2023

If you record, is the recorded file also laggy? (with stuttering)

scrcpy --record=file.mp4

What is the output in the console if you run scrcpy --print-fps?

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

Is it better with a lower resolution:

scrcpy -m1024

?

no difference, i tried with different cables too

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

If you record, is the recorded file also laggy? (with stuttering)

scrcpy --record=file.mp4

What is the output in the console if you run scrcpy --print-fps?

its running on 10fps and below, no wonder, how do i run it on high fps

@rom1v
Copy link
Collaborator

rom1v commented Dec 4, 2023

its running on 10fps and below, no wonder, how do i run it on high fps

OK, it's an issue on the device side then.

Try with another encoder: https://github.com/Genymobile/scrcpy/blob/master/doc/video.md#encoder

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

its running on 10fps and below, no wonder, how do i run it on high fps

OK, it's an issue on the device side then.

Try with another encoder: https://github.com/Genymobile/scrcpy/blob/master/doc/video.md#encoder

what code should i try

@rom1v
Copy link
Collaborator

rom1v commented Dec 4, 2023

scrcpy --list-encoders

Then try with one of the encoders listed, as in the example pointed by the link I posted.

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

C:\scrcpy-win64-v2.3.1\scrcpy-server: 1 file pushed, 0 skipped. 84.1 MB/s (66007 bytes in 0.001s)
[server] INFO: Device: [OnePlus] OnePlus 11R (Android 12)
[server] ERROR: Could not create default video encoder for av1
List of video encoders:
--video-codec=h264 --video-encoder='OMX.qcom.video.encoder.avc'
--video-codec=h264 --video-encoder='c2.android.avc.encoder'
--video-codec=h264 --video-encoder='OMX.google.h264.encoder'
--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'
--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc.cq'
--video-codec=h265 --video-encoder='c2.android.hevc.encoder'
[server] ERROR: Exception on thread Thread[video,5,main]
java.lang.IllegalArgumentException: Failed to initialize video/av01, error 0xfffffffe
at android.media.MediaCodec.native_setup(Native Method)
at android.media.MediaCodec.(MediaCodec.java:1961)
at android.media.MediaCodec.createEncoderByType(MediaCodec.java:1923)
at com.genymobile.scrcpy.SurfaceEncoder.createMediaCodec(SurfaceEncoder.java:207)
at com.genymobile.scrcpy.SurfaceEncoder.streamScreen(SurfaceEncoder.java:52)
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)
ERROR: "adb reverse --remove" returned with value 1
ERROR: Could not retrieve device information
ERROR: Server connection failed

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

C:\scrcpy-win64-v2.3.1>scrcpy --v4l2-buffer=300
scrcpy 2.3.1 https://github.com/Genymobile/scrcpy
ERROR: V4L2 (--v4l2-buffer) is disabled (or unsupported on this platform).
another issue

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

C:\scrcpy-win64-v2.3.1>scrcpy --list-encoders
scrcpy 2.3.1 https://github.com/Genymobile/scrcpy
INFO: ADB device found:
INFO: --> (usb) 4bdba881 device AC2001
C:\scrcpy-win64-v2.3.1\scrcpy-server: 1 file pushed, 0 skipped. 90.3 MB/s (66007 bytes in 0.001s)
[server] INFO: Device: [OnePlus] OnePlus 11R (Android 12)
[server] INFO: List of video encoders:
--video-codec=h264 --video-encoder='OMX.qcom.video.encoder.avc'
--video-codec=h264 --video-encoder='c2.android.avc.encoder'
--video-codec=h264 --video-encoder='OMX.google.h264.encoder'
--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'
--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc.cq'
--video-codec=h265 --video-encoder='c2.android.hevc.encoder'
[server] INFO: List of audio encoders:
--audio-codec=opus --audio-encoder='c2.android.opus.encoder'
--audio-codec=aac --audio-encoder='c2.android.aac.encoder'
--audio-codec=aac --audio-encoder='OMX.google.aac.encoder'
--audio-codec=flac --audio-encoder='c2.android.flac.encoder'
--audio-codec=flac --audio-encoder='OMX.google.flac.encoder'

@rom1v
Copy link
Collaborator

rom1v commented Dec 4, 2023

[server] ERROR: Could not create default video encoder for av1

Of course, you don't have any AV1 encoder on your device, so if you request to use AV1 it will fail.

ERROR: V4L2 (--v4l2-buffer) is disabled (or unsupported on this platform).

Video4Linux2 is only supported on Linux.

--video-codec=h264 --video-encoder='OMX.qcom.video.encoder.avc'
--video-codec=h264 --video-encoder='c2.android.avc.encoder'
--video-codec=h264 --video-encoder='OMX.google.h264.encoder'
--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'
--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc.cq'
--video-codec=h265 --video-encoder='c2.android.hevc.encoder'

Then test each one of these.

scrcpy --video-codec=h264 --video-encoder='OMX.qcom.video.encoder.avc'
…
scrcpy --video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'
…

EDIT: btw, if it does not work with quotes on Windows, remove the quotes:

scrcpy --video-codec=h264 --video-encoder=OMX.qcom.video.encoder.avc
…
scrcpy --video-codec=h265 --video-encoder=OMX.qcom.video.encoder.hevc
…

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

[server] ERROR: Could not create default video encoder for av1

Of course, you don't have any AV1 encoder on your device, so if you request to use AV1 it will fail.

ERROR: V4L2 (--v4l2-buffer) is disabled (or unsupported on this platform).

Video4Linux2 is only supported on Linux.

--video-codec=h264 --video-encoder='OMX.qcom.video.encoder.avc'
--video-codec=h264 --video-encoder='c2.android.avc.encoder'
--video-codec=h264 --video-encoder='OMX.google.h264.encoder'
--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'
--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc.cq'
--video-codec=h265 --video-encoder='c2.android.hevc.encoder'

Then test each one of these.

scrcpy --video-codec=h264 --video-encoder='OMX.qcom.video.encoder.avc'
…
scrcpy --video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'
…

i just ran them, its got to do with something of my device, i dont think can fix it, i think its just my phone thats messing it up

@rom1v
Copy link
Collaborator

rom1v commented Dec 4, 2023

i just ran them, its got to do with something of my device, i dont think can fix it, i think its just my phone thats messing it up

What the output when you run:

scrcpy --video-codec=h265 --video-encoder=OMX.qcom.video.encoder.hevc

?

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

C:\scrcpy-win64-v2.3.1>scrcpy --video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'
scrcpy 2.3.1 https://github.com/Genymobile/scrcpy
INFO: ADB device found:
INFO: --> (usb) 4bdba881 device AC2001
C:\scrcpy-win64-v2.3.1\scrcpy-server: 1 file pushed, 0 skipped. 119.0 MB/s (66007 bytes in 0.001s)
[server] INFO: Device: [OnePlus] OnePlus 11R (Android 12)
INFO: Renderer: direct3d
INFO: Texture: 1080x2400

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

isnt 119mb/s too high

@rom1v
Copy link
Collaborator

rom1v commented Dec 4, 2023

Please record and post the file, so that I see how it lags.

scrcpy --video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc' -m1024 --record=file.mp4

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

Watch the ending, it took so long to open too!!
Uploading file.mp4…

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

Its not letting me upload pass me ur email rq

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

file.mp4

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

just download this file and use vlc to open it

@rom1v
Copy link
Collaborator

rom1v commented Dec 4, 2023

just download this file and use vlc to open it

👍 (yes, webbrowsers do not support H.265)

Indeed, the capture is very laggy.

If you record with screenrecord (without scrcpy), is it the same problem?

adb shell screenrecord /sdcard/file.mp4
adb pull /sdcard/file.mp4

Is your physical screen broken by any chance? If so, try to turn the screen off: scrcpy --turn-screen-off.

EDIT: Oh, apparently, yes:

my phones lcd just came out of the phone a day ago

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

just download this file and use vlc to open it

👍 (yes, webbrowsers do not support H.265)

Indeed, the capture is very laggy.

If you record with screenrecord (without scrcpy), is it the same problem?

adb shell screenrecord /sdcard/file.mp4
adb pull /sdcard/file.mp4

Is your physical screen broken by any chance? If so, try to turn the screen off: scrcpy --turn-screen-off.

EDIT: Oh, apparently, yes:

my phones lcd just came out of the phone a day ago

the issue isnt the recording its the phone, i think its time to give up and just learn to live with it, gg, thanks for helping me tho, ur a gee

@rom1v
Copy link
Collaborator

rom1v commented Dec 4, 2023

As I suggested in my previous message, the problem is that the screen is broken/disconnected, which causes capture vsync issues.

Running scrcpy --turn-screen-off solves the problem on many devices. See #3840

@tanzz107
Copy link
Author

tanzz107 commented Dec 4, 2023

brooooo,it workssss!!!!!, my goatttttttttttt ily man

@rom1v rom1v closed this as completed Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants