Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
105.36k stars 10.23k forks source link

[scrcpy 2.0] audio Exception #3791

Open Ryan2009 opened 1 year ago

Ryan2009 commented 1 year ago

Environment

Describe the bug A clear and concise description of what the bug is.

scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 42.8 MB/s (52867 bytes in 0.001s)
[server] INFO: Device: redroid redroid12_arm64 (Android 12)
[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.<init>(MediaCodec.java:1961)
        at android.media.MediaCodec.createEncoderByType(MediaCodec.java:1923)
        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:920)
WARN: Demuxer 'audio': stream explicitly disabled by the device
WARN: Audio stream recording disabled
INFO: Recording started to mp4 file: file.mp4

adb logcat :

03-12 10:01:01.356 38880 39017 E GODZILLA: Original size is 1064960 but real size is 536576
03-12 10:01:04.084 40663 40663 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
03-12 10:01:04.088 40663 40663 I AndroidRuntime: Using default boot image
03-12 10:01:04.088 40663 40663 I AndroidRuntime: Leaving lock profiling enabled
03-12 10:01:04.090 40663 40663 W app_process: ART APEX data files are untrusted.
03-12 10:01:04.090 40663 40663 I app_process: Core platform API reporting enabled, enforcing=false
03-12 10:01:04.158 40663 40663 D app_process: Time zone APEX ICU file found: /apex/com.android.tzdata/etc/icu/icu_tzdata.dat
03-12 10:01:04.158 40663 40663 D app_process: I18n APEX ICU file found: /apex/com.android.i18n/etc/icu/icudt68l.dat
03-12 10:01:04.181 40663 40663 D AndroidRuntime: Calling main entry com.genymobile.scrcpy.Server
03-12 10:01:04.182 40663 40663 I scrcpy  : Device: redroid redroid12_arm64 (Android 12)
03-12 10:01:04.198 40663 40663 D MtpDeviceJNI: register_android_mtp_MtpDevice
03-12 10:01:04.200 40663 40682 W MediaCodec-JNI: try to release MediaCodec from JMediaCodec::~JMediaCodec()...
03-12 10:01:04.200 40663 40663 D MediaCodecList: codecHandlesFormat: no format, so no extra checks
03-12 10:01:04.200 40663 40682 W MediaCodec-JNI: done releasing MediaCodec from JMediaCodec::~JMediaCodec().
03-12 10:01:04.200 40663 40682 E AndroidRuntime: FATAL EXCEPTION: Thread-4
03-12 10:01:04.200 40663 40682 E AndroidRuntime: PID: 40663
03-12 10:01:04.200 40663 40682 E AndroidRuntime: java.lang.IllegalArgumentException: Failed to initialize audio/opus, error 0xfffffffe
03-12 10:01:04.200 40663 40682 E AndroidRuntime:        at android.media.MediaCodec.native_setup(Native Method)
03-12 10:01:04.200 40663 40682 E AndroidRuntime:        at android.media.MediaCodec.<init>(MediaCodec.java:1961)
03-12 10:01:04.200 40663 40682 E AndroidRuntime:        at android.media.MediaCodec.createEncoderByType(MediaCodec.java:1923)
03-12 10:01:04.200 40663 40682 E AndroidRuntime:        at com.genymobile.scrcpy.AudioEncoder.createMediaCodec(AudioEncoder.java:278)
03-12 10:01:04.200 40663 40682 E AndroidRuntime:        at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:174)
03-12 10:01:04.200 40663 40682 E AndroidRuntime:        at com.genymobile.scrcpy.AudioEncoder.lambda$start$0$com-genymobile-scrcpy-AudioEncoder(AudioEncoder.java:120)
03-12 10:01:04.200 40663 40682 E AndroidRuntime:        at com.genymobile.scrcpy.AudioEncoder$$ExternalSyntheticLambda0.run(Unknown Source:2)
03-12 10:01:04.200 40663 40682 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:920)
03-12 10:01:04.200 40663 40682 E scrcpy  : Exception on thread Thread[Thread-4,5,main]
03-12 10:01:04.200 40663 40682 E scrcpy  : java.lang.IllegalArgumentException: Failed to initialize audio/opus, error 0xfffffffe
03-12 10:01:04.200 40663 40682 E scrcpy  :      at android.media.MediaCodec.native_setup(Native Method)
03-12 10:01:04.200 40663 40682 E scrcpy  :      at android.media.MediaCodec.<init>(MediaCodec.java:1961)
03-12 10:01:04.200 40663 40682 E scrcpy  :      at android.media.MediaCodec.createEncoderByType(MediaCodec.java:1923)
03-12 10:01:04.200 40663 40682 E scrcpy  :      at com.genymobile.scrcpy.AudioEncoder.createMediaCodec(AudioEncoder.java:278)
03-12 10:01:04.200 40663 40682 E scrcpy  :      at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:174)
03-12 10:01:04.200 40663 40682 E scrcpy  :      at com.genymobile.scrcpy.AudioEncoder.lambda$start$0$com-genymobile-scrcpy-AudioEncoder(AudioEncoder.java:120)
03-12 10:01:04.200 40663 40682 E scrcpy  :      at com.genymobile.scrcpy.AudioEncoder$$ExternalSyntheticLambda0.run(Unknown Source:2)
03-12 10:01:04.200 40663 40682 E scrcpy  :      at java.lang.Thread.run(Thread.java:920)
03-12 10:01:04.201 40663 40685 I OMXClient: IOmx service obtained
03-12 10:01:04.201   121   327 I OMXStore: makeComponentInstance(OMX.google.h264.encoder) in android.hardwar process
03-12 10:01:04.207 40663 40663 D CodecSeeding: Seed: codec OMX.google.h264.encoder, mediatype video/avc, overrideable 1
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-bpp,0)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-bpp-1080p,1.90)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-bpp-720p,2.25)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-bpp-540p,2.65)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-bpp-480p,3.00)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-bpp-320x240,0)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-qpmax,-1)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-qpmax-1080p,45)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-qpmax-720p,43)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-qpmax-540p,42)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-target-qpmax-480p,38)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-bitrate-phaseout,1.75)
03-12 10:01:04.207 40663 40663 D CodecProperties: setTuningValue(vq-boost-missing-qp,0.20)
03-12 10:01:04.207 40663 40663 D CodecProperties: setFeatureValue(intra-refresh,0)
03-12 10:01:04.207 40663 40663 D CodecProperties: setFeatureValue(_vq_eligible.device,1)
03-12 10:01:04.207 40663 40663 D CodecProperties: setFeatureValue(_quality.target,1)
03-12 10:01:04.207 40663 40663 D CodecSeeding: Seed: codec OMX.google.h264.encoder, mediatype video/avc, overrideable 0
03-12 10:01:04.207 40663 40663 D MediaCodec: shapeMediaFormat: deltas(1): AMessage(what = 0x00000000) = {
03-12 10:01:04.207 40663 40663 D MediaCodec:     int32_t android._encoding-quality-level = 0
03-12 10:01:04.207 40663 40663 D MediaCodec:   }
03-12 10:01:04.208 40663 40685 W OMXUtils: do not know color format 0x7f000789 = 2130708361
03-12 10:01:04.208 40663 40685 I ACodec  : setupAVCEncoderParameters with [profile: Baseline] [level: Level41]
03-12 10:01:04.208 40663 40685 I ACodec  : [OMX.google.h264.encoder] cannot encode color aspects. Ignoring.
03-12 10:01:04.208 40663 40685 I ACodec  : [OMX.google.h264.encoder] cannot encode HDR static metadata. Ignoring.
03-12 10:01:04.208 40663 40685 I ACodec  : setupVideoEncoder succeeded
03-12 10:01:04.208 40663 40685 W OMXUtils: do not know color format 0x7f000789 = 2130708361
03-12 10:01:04.209   121   327 E OMXNodeInstance: getConfig(0xe5a00c50:google.h264.encoder, ConfigLatency(0x6f800005)) ERROR: Undefined(0x80001001)
03-12 10:01:04.209   121   327 E OMXNodeInstance: getConfig(0xe5a00c50:google.h264.encoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
03-12 10:01:04.209   121   327 D GraphicBufferSource: setting dataspace: 0x104, acquired=0
03-12 10:01:04.209   121   327 D GraphicBufferSource: requesting color aspects (R:2(Limited), P:1(BT709_5), M:1(BT709_5), T:3(SMPTE170M))
03-12 10:01:04.219   117   328 W ResourceManagerService: Ignoring request to add new resource entry with value <= 0
03-12 10:01:04.224   121 40687 D SoftAVCEnc: Params width 1080 height 1920 level 41 colorFormat 0
03-12 10:01:04.245 40678 40678 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
03-12 10:01:04.249 40678 40678 I AndroidRuntime: Using default boot image
03-12 10:01:04.249 40678 40678 I AndroidRuntime: Leaving lock profiling enabled
03-12 10:01:04.251 40678 40678 W app_process: ART APEX data files are untrusted.
03-12 10:01:04.251 40678 40678 I app_process: Core platform API reporting enabled, enforcing=false
ChaunceyWang2021 commented 1 year ago

Same problem as you, in Kubuntu 22.04 LTS.

rom1v commented 1 year ago

It seems there is no OPUS encoder on your device.

scrcpy --list-encoders
scrcpy --audio-encoder=aac
Ryan2009 commented 1 year ago

It seems there is no OPUS encoder on your device.

scrcpy --list-encoders
scrcpy --audio-encoder=aac

It's ok in redroid. but other exception in my phone. android 12.

[server] INFO: Device: vivo V2055A (Android 12)
[server] ERROR: Exception on thread Thread[Thread-4,5,main]
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getOpPackageName()' on a null object reference
        at android.media.VivoAudioRecordImpl.isSupportSubMixRecording(VivoAudioRecordImpl.java:133)
        at android.media.AudioRecord.<init>(AudioRecord.java:497)
        at android.media.AudioRecord.<init>(AudioRecord.java:91)
        at android.media.AudioRecord$Builder.build(AudioRecord.java:935)
        at com.genymobile.scrcpy.AudioCapture.createAudioRecord(AudioCapture.java:58)
        at com.genymobile.scrcpy.AudioCapture.start(AudioCapture.java:90)
        at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:183)
        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:922)
INFO: Recording started to matroska file: file.mkv
INFO: Renderer: direct3d
WARN: Demuxer 'audio': stream explicitly disabled by the device
WARN: Audio stream recording disabled
INFO: Initial texture: 1080x2400
INFO: Recording complete to matroska file: file.mkv
rom1v commented 1 year ago

Yes, for this vivo phone it does not work. See https://github.com/Genymobile/scrcpy/pull/3757#issuecomment-1454326127

A-viral-dev commented 1 year ago

can i help in any way to solve this issue?

Lautsprecher commented 1 year ago

Same on Nvidia Shield Android TV 9.1.1(33.2.0.157)...

C:\adbLink>scrcpy.exe  -s 192.168.2.181:5555
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
C:\adbLink\adbfiles\scrcpy\scrcpy-... file pushed, 0 skipped. 10.6 MB/s (52867 bytes in 0.005s)
[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.<init>(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)
INFO: Renderer: direct3d
ERROR: Demuxer 'video': stream disabled due to connection error
WARN: Demuxer 'audio': stream explicitly disabled by the device
ERROR: Demuxer error
[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.<init>(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)
WARN: Killing the server...
rom1v commented 1 year ago

@Lautsprecher #3801

@Ryan2009 Could you please test whether https://github.com/Genymobile/scrcpy/issues/3801#issuecomment-1468897171 also fixes your issue?

Lautsprecher commented 1 year ago

@Lautsprecher #3801

@Ryan2009 Could you please test whether #3801 (comment) also fixes your issue?

With --no-audio scrcpy will start, Thanks for the Link

rom1v commented 1 year ago

@Lautsprecher and with audio, scrcpy --audio-codec=aac and https://github.com/Genymobile/scrcpy/issues/3801#issuecomment-1468897171 ?

Lautsprecher commented 1 year ago

@Lautsprecher and with audio, scrcpy --audio-codec=aac and #3801 (comment) ?

Wow, with replaced scrcpy-server file i also got Audio :) Thank You!

A-viral-dev commented 1 year ago

audio is still not working with the new file #3801 on My Vivo smartphone.

rom1v commented 1 year ago

@A-viral-dev OK thank you. So no solution for vivo phones (#3805)… :disappointed:

rom1v commented 1 year ago

Could you please adb pull /system/framework/framework.jar from your Vivo device and post your framework.jar (similar to https://github.com/Genymobile/scrcpy/issues/3801#issuecomment-1468362200), to check what android.media.VivoAudioRecordImpl.isSupportSubMixRecording() is doing.

A-viral-dev commented 1 year ago

Here's the file link

rom1v commented 1 year ago

Thank you. Could you please paste the full error you have in the console. Is it exactly the same as #3805 ?

A-viral-dev commented 1 year ago

Yes, same error.

rom1v commented 1 year ago

OK (of course, you are the author of #3805 :smile: )

at android.media.VivoAudioRecordImpl.isSupportSubMixRecording(VivoAudioRecordImpl.java:133)

I could not find any VivoAudioRecordImpl, only VivoAudioRecord.

Any idea @yume-chan?

rom1v commented 1 year ago

Maybe it's in another jar.

What is the result of adb shell ls /system/framework?

A-viral-dev commented 1 year ago

QPerformance.jar QXPerformance.jar UxPerformance.jar WfdCommon.jar abx.jar am.jar android.hardware.wifi.supplicant-V1.0-java.jar android.hardware.wifi.supplicant-V1.1-java.jar android.hardware.wifi.supplicant-V1.2-java.jar android.hardware.wifi.supplicant-V1.3-java.jar android.hidl.base-V1.0-java.jar android.hidl.manager-V1.0-java.jar android.test.base.jar android.test.mock.jar android.test.runner.jar appwidget.jar arm arm64 bmgr.jar boot-QPerformance.vdex boot-UxPerformance.vdex boot-WfdCommon.vdex boot-core-icu4j.vdex boot-ext.vdex boot-framework-adapter.vdex boot-framework-graphics.vdex boot-framework.vdex boot-ims-common.vdex boot-qcom.fmradio.vdex boot-soc-framework.vdex boot-tcmiface.vdex boot-telephony-common.vdex boot-telephony-ext.vdex boot-vivo-framework.vdex boot-vivo-media.vdex boot-vivo-vgcclient.vdex boot-voip-common.vdex bu.jar com.android.future.usb.accessory.jar com.android.location.provider.jar com.android.media.remotedisplay.jar com.android.mediadrm.signer.jar com.android.wm.shell.jar com.novatek.framework.jar content.jar ext.jar framework-adapter.jar framework-graphics.jar framework-res.apk framework.jar hid.jar ims-common.jar incident-helper-cmd.jar javax.obex.jar locksettings.jar monkey.jar oat org.apache.http.legacy.jar org.apache.http.legacy.jar.prof qcom.fmradio.jar requestsync.jar services-adapter.jar services.jar services.jar.bprof services.jar.prof sm.jar soc-framework.jar soc-services.jar svc.jar tcmclient.jar tcmiface.jar telecom.jar telephony-common.jar telephony-ext.jar uiautomator.jar uinput.jar vendor.qti.hardware.radio.qtiradio-V1-java.jar vivo-framework.jar vivo-media.jar vivo-priv-telephony-common.jar vivo-res.apk vivo-services.jar vivo-telephony-common-platform-ex.jar vivo-telephony-common.jar vivo-telephony-ext.jar vivo-vgcclient.jar voip-common.jar vr.jar wapicertstore.jar wmshellapp.apk

rom1v commented 1 year ago

Maybe:

adb pull /system/framework/vivo-framework.jar
adb pull /system/framework/vivo-media.jar
A-viral-dev commented 1 year ago

Vivo-framework.jar

A-viral-dev commented 1 year ago

Vivo-media.jar

Ryan2009 commented 1 year ago

@Lautsprecher #3801

@Ryan2009 Could you please test whether #3801 (comment) also fixes your issue?

Please test (replace this binary in the v2.0 release):

scrcpy-server SHA-256: 4f40f140ddf14f62c0ff47c47071471a4d3adef827126388b5cd064c7b919d8d

[server] INFO: Device: vivo V2055A (Android 12)
[server] ERROR: Exception on thread Thread[Thread-4,5,main]
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getOpPackageName()' on a null object reference
        at android.media.VivoAudioRecordImpl.isSupportSubMixRecording(VivoAudioRecordImpl.java:133)
        at android.media.AudioRecord.<init>(AudioRecord.java:497)
        at android.media.AudioRecord.<init>(AudioRecord.java:91)
        at android.media.AudioRecord$Builder.build(AudioRecord.java:935)
        at com.genymobile.scrcpy.AudioCapture.createAudioRecord(AudioCapture.java:58)
        at com.genymobile.scrcpy.AudioCapture.start(AudioCapture.java:90)
        at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:183)
        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:922)
INFO: Renderer: direct3d
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Initial texture: 1080x2400

I use the scrcpy-server , met the same issue. this jar get from myphone

vivo-media.zip

crzymelly commented 1 year ago

@Lautsprecher #3801 @Ryan2009 Could you please test whether #3801 (comment) also fixes your issue?

Please test (replace this binary in the v2.0 release):

scrcpy-server SHA-256: 4f40f140ddf14f62c0ff47c47071471a4d3adef827126388b5cd064c7b919d8d

[server] INFO: Device: vivo V2055A (Android 12)
[server] ERROR: Exception on thread Thread[Thread-4,5,main]
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getOpPackageName()' on a null object reference
        at android.media.VivoAudioRecordImpl.isSupportSubMixRecording(VivoAudioRecordImpl.java:133)
        at android.media.AudioRecord.<init>(AudioRecord.java:497)
        at android.media.AudioRecord.<init>(AudioRecord.java:91)
        at android.media.AudioRecord$Builder.build(AudioRecord.java:935)
        at com.genymobile.scrcpy.AudioCapture.createAudioRecord(AudioCapture.java:58)
        at com.genymobile.scrcpy.AudioCapture.start(AudioCapture.java:90)
        at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:183)
        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:922)
INFO: Renderer: direct3d
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Initial texture: 1080x2400

I use the scrcpy-server , met the same issue. this jar get from myphone

vivo-media.zip

Did the above and met with the same issue. Attached is the jar from my phone. vivo-media_framework.zip Thanks.

A-viral-dev commented 1 year ago

we should merge #3805 and all other Vivo issues in one thread