-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Connecting to Nvidia Shield - error with scrcpy 2.0 #3801
Comments
Could you please try with |
Hi rom1v, That works, thanks :) scrcpy --no-audio |
OK so the FakeContext to make audio works seems to break your video. (cc @yume-chan for information) |
Came to post about this issue, can verify on My Shield Pro 2019 also. |
There is no opus encoder, can you try Also what will happen if you run I imagine if there was no |
scrcpy --audio-codec=aac --audio-encoder='OMX.google.aac.encoder' scrcpy --no-audio --video-codec=h265 --video-encoder='OMX.Nvidia.h265.encoder' "I imagine if there was no Context by default it will throw the same error?" See details below.
|
@rom1v Scrcpy server process doesn't have any associated Without knowing exactly what the code is doing, it's impossible to know which methods need to be patched. @cpo-ux can you pull out the |
@yume-chan Was my first time doing this so took me a while to figure out... In the end I gave up on ADB shell stuff and used: https://github.com/Alex4SSB/ADB-Explorer] I am assuming there's no personal info in this file I'm uploading :) File is at google drive link here: https://drive.google.com/file/d/1YPcyASPUFspoayYGoUNQQo63fQmUmk0V/view?usp=sharing |
adb pull /system/framework/framework.jar /path/on/your/pc
This is the Java part of your Android system. I was right that it guarded against empty Context, but when Context exists, it invokes multiple methods including These definitely requires a real App Context, I don't think it's possible to emulate them in FakeContext. Maybe I need to check how App Context was initialized... Or try to hook the framework API calls... |
Also running into this issue on my Nvidia Shield running Android 11, and can report that |
Audio requires an app context, but it seems that the workarounds which makes Nvidia Shield fail are unrelated workarounds for Meizu phones. So let's try to split them: 3582592 Please test (replace this binary in the v2.0 release):
|
That scrcpy-server binary works. I still get the |
|
Thanks! Audio streaming works now on the Shield using the AAC codec. |
👌 Merged into |
FWIW,
This works for me on my Shield Pro, many thanks! |
This also works on my meizu m3 note. Thanks a lot! |
will this change be merged into the next release, or will this always stay as a manual fix?
This works, but in case someone else is wondering why it doesn't work, no Bluetooth headset can be connected. |
It is already merged into the |
perfect, thanks! |
Environment:
OS: Win 10 Pro x64 22H2
scrcpy version: 2.0
Installation method: Windows release
device model: NVIDIA SHIELD Model P2897 year: 2017
Android version: 11
Hi,
Version 1.25 works fine so I'll stay with it for now however I thought I'd try the latest version of scrcpy 2.0 and it doesn't work; I get the following, below.
C:\MorePrograms1\scrcpy-win64_2.0>scrcpy
scrcpy 2.0 https://github.com/Genymobile/scrcpy
C:\MorePrograms1\scrcpy-win64_2.0\scrcpy-server: 1 file pushed, 0 skipped. 42.6 MB/s (52867 bytes in 0.001s)
[server] INFO: Device: NVIDIA SHIELD Android TV (Android 11)
[server] ERROR: Exception on thread Thread[Thread-4,5,main]
java.lang.IllegalArgumentException: Failed to initialize audio/opus, error 0xfffffffe
at android.media.MediaCodec.native_setup(Native Method)
at android.media.MediaCodec.(MediaCodec.java:2117)
at android.media.MediaCodec.createEncoderByType(MediaCodec.java:2042)
at com.genymobile.scrcpy.AudioEncoder.createMediaCodec(AudioEncoder.java:278)
at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:174)
at com.genymobile.scrcpy.AudioEncoder.lambda$start$0$com-genymobile-scrcpy-AudioEncoder(AudioEncoder.java:120)
at com.genymobile.scrcpy.AudioEncoder$$ExternalSyntheticLambda0.run(Unknown Source:2)
at java.lang.Thread.run(Thread.java:923)
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.createPackageContext(java.lang.String, int)' on a null object reference
at android.content.ContextWrapper.createPackageContext(ContextWrapper.java:927)
at android.content.ContextWrapper.createPackageContext(ContextWrapper.java:927)
at android.media.MediaCodec.isSupported(MediaCodec.java:1892)
at android.media.MediaCodec.checkAppForAutoFrc(MediaCodec.java:1922)
at android.media.MediaCodec.configureCodecParams(MediaCodec.java:2084)
at android.media.MediaCodec.(MediaCodec.java:2118)
at android.media.MediaCodec.createEncoderByType(MediaCodec.java:2042)
at com.genymobile.scrcpy.ScreenEncoder.createMediaCodec(ScreenEncoder.java:209)
at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:64)
at com.genymobile.scrcpy.Server.scrcpy(Server.java:133)
at com.genymobile.scrcpy.Server.main(Server.java:381)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:399)
INFO: Renderer: direct3d
ERROR: Demuxer 'audio': stream disabled due to connection error
ERROR: Demuxer 'video': stream disabled due to connection error
ERROR: Demuxer error
WARN: Killing the server...
===================
I also tried different codecs and encoders with the instructions from here but no luck and got this error because there's something wrong with the command for the encoder:
C:\MorePrograms1\scrcpy-win64_2.0>scrcpy --list-encoders
scrcpy 2.0 https://github.com/Genymobile/scrcpy
C:\MorePrograms1\scrcpy-win64_2.0\scrcpy-server: 1 file pushed, 0 skipped. 34.9 MB/s (52867 bytes in 0.001s)
[server] INFO: List of video encoders:
--video-codec=h264 --video-encoder='OMX.Nvidia.h264.encoder'
--video-codec=h264 --video-encoder='OMX.google.h264.encoder'
--video-codec=h265 --video-encoder='OMX.Nvidia.h265.encoder'
[server] INFO: List of audio encoders:
--audio-codec=aac --audio-encoder='OMX.google.aac.encoder'
C:\MorePrograms1\scrcpy-win64_2.0>scrcpy --video-codec=h265 --video-encoder='OMX.Nvidia.h265.encoder'
scrcpy 2.0 https://github.com/Genymobile/scrcpy
C:\MorePrograms1\scrcpy-win64_2.0\scrcpy-server: 1 file pushed, 0 skipped. 38.8 MB/s (52867 bytes in 0.001s)
[server] INFO: Device: NVIDIA SHIELD Android TV (Android 11)
[server] ERROR: Audio encoding error
java.io.IOException: android.system.ErrnoException: write failed: EBADF (Bad file descriptor)
at com.genymobile.scrcpy.IO.writeFully(IO.java:33)
at com.genymobile.scrcpy.IO.writeFully(IO.java:40)
at com.genymobile.scrcpy.Streamer.writeDisableStream(Streamer.java:61)
at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:224)
at com.genymobile.scrcpy.AudioEncoder.lambda$start$0$com-genymobile-scrcpy-AudioEncoder(AudioEncoder.java:120)
at com.genymobile.scrcpy.AudioEncoder$$ExternalSyntheticLambda0.run(Unknown Source:2)
at java.lang.Thread.run(Thread.java:923)
Caused by: android.system.ErrnoException: write failed: EBADF (Bad file descriptor)
at libcore.io.Linux.writeBytes(Native Method)
at libcore.io.Linux.write(Linux.java:285)
at libcore.io.ForwardingOs.write(ForwardingOs.java:239)
at libcore.io.BlockGuardOs.write(BlockGuardOs.java:412)
at android.system.Os.write(Os.java:727)
at com.genymobile.scrcpy.IO.writeFully(IO.java:25)
... 6 more
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.createPackageContext(java.lang.String, int)' on a null object reference
at android.content.ContextWrapper.createPackageContext(ContextWrapper.java:927)
at android.content.ContextWrapper.createPackageContext(ContextWrapper.java:927)
at android.media.MediaCodec.isSupported(MediaCodec.java:1892)
at android.media.MediaCodec.checkForSecureDecoder(MediaCodec.java:1936)
at android.media.MediaCodec.createByCodecName(MediaCodec.java:2058)
at com.genymobile.scrcpy.ScreenEncoder.createMediaCodec(ScreenEncoder.java:203)
at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:64)
at com.genymobile.scrcpy.Server.scrcpy(Server.java:133)
at com.genymobile.scrcpy.Server.main(Server.java:381)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:399)
INFO: Renderer: direct3d
ERROR: Demuxer 'audio': stream disabled due to connection error
ERROR: Demuxer 'video': stream disabled due to connection error
ERROR: Demuxer error
============
Not sure what else to try...
The text was updated successfully, but these errors were encountered: