Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
112.24k stars 10.73k forks source link

Cannot record screen from BlueStacks #4447

Open selimsum opened 12 months ago

selimsum commented 12 months ago

Environment

I'm trying to record the screen from BlueStacks.

C:\scrcpy>scrcpy  --no-playback --record=file.mp4 --audio-codec=aac --audio-encoder='OMX.google.aac.encoder'
scrcpy v2.2 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)       127.0.0.1:64835            device  SM_S901E
C:\scrcpy\scrcpy-server: 1 file pushed, 0 skipped. 92.1 MB/s (64363 bytes in 0.001s)
[server] INFO: Device: [samsung] samsung SM-S901E (Android 11)
INFO: Recording started to mp4 file: file.mp4
WARN: [FFmpeg] track 1: codec frame size is not set
ERROR: Recording failed to file.mp4

I've also tried the following but the result is a 1KB non-working file:

C:\scrcpy>scrcpy  --no-playback --record=file.mp4 --no-audio
scrcpy v2.2 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)       127.0.0.1:64835            device  SM_S901E
C:\scrcpy\scrcpy-server: 1 file pushed, 0 skipped. 107.8 MB/s (64363 bytes in 0.001s)
[server] INFO: Device: [samsung] samsung SM-S901E (Android 11)
INFO: Recording started to mp4 file: file.mp4
INFO: Recording complete to mp4 file: file.mp4
rom1v commented 12 months ago

Does mirroring work?

selimsum commented 12 months ago

Is simply running scrcpy supposed to launch mirroring? If yes, then it doesn't work.

C:\scrcpy>scrcpy
scrcpy v2.2 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)       127.0.0.1:50132            device  SM_S901E
C:\scrcpy\scrcpy-server: 1 file pushed, 0 skipped. 125.1 MB/s (64363 bytes in 0.000s)
[server] INFO: Device: [samsung] samsung SM-S901E (Android 11)
[server] ERROR: Could not create default audio encoder for opus
List of audio encoders:
    --audio-codec=aac --audio-encoder='OMX.google.aac.encoder'
[server] ERROR: Exception on thread Thread[audio-encoder,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:292)
        at com.genymobile.scrcpy.AudioEncoder.encode(AudioEncoder.java:184)
        at com.genymobile.scrcpy.AudioEncoder.lambda$start$0$com-genymobile-scrcpy-AudioEncoder(AudioEncoder.java:124)
        at com.genymobile.scrcpy.AudioEncoder$$ExternalSyntheticLambda0.run(Unknown Source:4)
        at java.lang.Thread.run(Thread.java:923)
INFO: Renderer: direct3d
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Texture: 720x1280
rom1v commented 12 months ago

Is simply running scrcpy supposed to launch mirroring?

Yes. Try with a real device.

selimsum commented 12 months ago

Even if it does work with a real device, it doesn't help with my case. I need to make it work with an emulator. It doesn't have to be BlueStacks but it did work with BlueStacks before. See the previous issue I've filed: #4054

rom1v commented 12 months ago

Does an older version of scrcpy work on your current bluestack? Does screenrecord work (adb shell screenrecord /sdcard/file.mp4)?

Try with another encoder (scrcpy --list-encoders).

selimsum commented 12 months ago

Does an older version of scrcpy work on your current bluestack?

I've tried 2.1 and 2.0. They don't work. However, I remember that 2.0 worked with a previous version of BlueStacks. (Not sure which version.)

Does screenrecord work (adb shell screenrecord /sdcard/file.mp4)?

The output is a 4KB non-working file.

Try with another encoder (scrcpy --list-encoders).

These are the only encoders available in BlueStacks.

C:\scrcpy>scrcpy --list-encoders
scrcpy v2.2 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)       127.0.0.1:59429            device  SM_S901E
C:\scrcpy\scrcpy-server: 1 file pushed, 0 skipped. 175.2 MB/s (64363 bytes in 0.000s)
[server] INFO: Device: [samsung] samsung SM-S901E (Android 11)
[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'

I haven't used BlueStacks for the past few months but it's likely that a BlueStacks update have rendered scrcpy unusable.

rom1v commented 12 months ago

Does screenrecord work (adb shell screenrecord /sdcard/file.mp4)?

The output is a 4KB non-working file.

OK so it's definitely a problem in the ROM (or bluestack): even the native screenrecorder doesn't work.