scrcpy: Audio capture fails on BlueStacks Android 11

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Windows 11
  • scrcpy version: 2.0
  • installation method: Windows release
  • device model: BlueStacks 5 (emulator)
  • Android version: 11

Describe the bug I’m trying to record the screen of a BlueStacks Android 11 (beta) instance.

First I’ve tried:

C:\scrcpy-win64-v2.0>scrcpy --record=file.mp4
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
C:\scrcpy-win64-v2.0\scrcpy-server: 1 file pushed, 0 skipped. 91.7 MB/s (52867 bytes in 0.001s)
[server] INFO: Device: samsung SM-S908E (Android 11)
INFO: Recording started to mp4 file: file.mp4
[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:1912)
        at android.media.MediaCodec.createEncoderByType(MediaCodec.java:1875)
        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
WARN: Demuxer 'audio': stream explicitly disabled by the device
WARN: Audio stream recording disabled
INFO: Initial texture: 720x1280
INFO: Recording complete to mp4 file: file.mp4

Then:

C:\scrcpy-win64-v2.0>scrcpy --list-encoders
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
C:\scrcpy-win64-v2.0\scrcpy-server: 1 file pushed, 0 skipped. 70.4 MB/s (52867 bytes in 0.001s)
[server] INFO: List of video encoders:
    --video-codec=h264 --video-encoder='OMX.google.h264.encoder'
[server] INFO: List of audio encoders:
    --audio-codec=aac --audio-encoder='OMX.google.aac.encoder'

And then:

C:\scrcpy-win64-v2.0>scrcpy --record=file.mp4 --audio-codec=aac --audio-encoder='OMX.google.aac.encoder'
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
C:\scrcpy-win64-v2.0\scrcpy-server: 1 file pushed, 0 skipped. 157.7 MB/s (52867 bytes in 0.000s)
[server] INFO: Device: samsung SM-S908E (Android 11)
INFO: Recording started to mp4 file: file.mp4
INFO: Renderer: direct3d
INFO: Initial texture: 720x1280
WARN: [FFmpeg] track 1: codec frame size is not set
ERROR: [FFmpeg] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 75968 >= 75792
ERROR: Could not record audio packet
ERROR: Recording failed to file.mp4

So I can capture video but not audio.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17

Commits related to this issue

Most upvoted comments

Thank you. I think I get it, it’s due to PTS rescaling. I will fix it soon.