Scrcpy: ERROR: Could not open video stream

Created on 8 Mar 2018  ·  19Comments  ·  Source: Genymobile/scrcpy

On Arch GNU/Linux, built scrcpy using the released .jar.

meson x --buildtype release --strip -Db_lto=true \
    -Dprebuilt_server=/path/to/scrcpy-server.jar
cd x
ninja
sudo ninja install

I have a Samsung Galaxy Note II N7100 running Replicant 6.0 0003.
The resulution should be 720x1280.

$ scrcpy -m 1280 
/usr/local/share/scrcpy/scrcpy-server.jar: 1 file pushed. 1.9 MB/s (19038 bytes in 0.009s)
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
ERROR: Could not open video stream
ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalStateException
    at android.media.MediaCodec.native_stop(Native Method)
    at android.media.MediaCodec.stop(MediaCodec.java:1901)
    at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:69)
    at com.genymobile.scrcpy.Server.scrcpy(Server.java:21)
    at com.genymobile.scrcpy.Server.main(Server.java:70)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:258)
INFO: Initial texture: 720x1280

Any ideas? I think Replicant may be the offender here.

Edit: installed android sdk aura -A android-sdk and built my own .jar; same result.

Edit2: Does not affect Samsung S9 with Stock or LineageOS

codec

Most helpful comment

@mikhoul Maybe you could increase the definition until it fails.

scrcpy -m 1024
scrcpy -m 1280
…

All 19 comments

I think Replicant may be the offender here.

Yes, probably it does not include something required to encode to H.264 in hardware.

Hi,

From Gentoo, i've got an error

/usr/local/share/scrcpy/scrcpy-server.jar: 1 file pushed. 1.8 MB/s (19038 bytes in 0.010s)
CRITICAL: Could not create renderer: Couldn't find matching render driver
ERROR: Could not open video stream

package installed media-video/ffmpeg-3.3.6:0/55.57.57::gentoo
but i can't install media-video/libav-11.8:0/11::gentoo

:-(

hi, I'm also on arch and try to use my chuwi hi12 both with precompiled scrcpy-server.jar and with self rolled current dev branch. both works very fine for some seconds and then crash with:

INFO: Initial texture: 2160x1440
Invalid return value 0 for stream protocol
ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalStateException
    at ERROR: Exception on thread Thread[Thread-10,5,main]
android.media.MediaCodec.native_stop(Native Method)
    at android.media.MediaCodec.stop(MediaCodec.java:628)
    at java.lang.AssertionError: java.lang.reflect.InvocationTargetException
    at com.genymobile.scrcpy.wrappers.InputManager.injectInputEvent(InputManager.java:31)
    at com.genymobile.scrcpy.Device.injectInputEvent(Device.java:97)
    at com.genymobile.scrcpy.EventController.injectEvent(EventController.java:163)
    at com.genymobile.scrcpy.EventController.injectMouse(EventController.java:133)
    at com.genymobile.scrcpy.EventController.handleEvent(EventController.java:79)
    at com.genymobile.scrcpy.EventController.control(EventController.java:65)
    at com.genymobile.scrcpy.Server$1.run(Server.java:34)
    at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.genymobile.scrcpy.wrappers.InputManager.injectInputEvent(InputManager.java:29)

installed is the original android (5.1 - rooted and free from preinstalled spyware)
any hints would be nice!
great project btw, thank you very much! found it today via cnx-software

while searching for the "Invalid return value 0 for stream protocol" crash, I found this mpv issue:
https://github.com/mpv-player/mpv/issues/5118. no idea if it is triggered by the same problem, but looks like it is caused by a "wrong backported ffmpeg", so it might be arch related. after many gentoo years I switched to arch for my main system just a few months ago, so I don't have too old ffmpeg versions in my pacman cache which could work. downgrading to ffmpeg-1:3.4.1-1 (and its dependencies of course) didn't help anything.

@Necklaces Did you find any solution to the error

Works well for my android device but not for the emulator. Heres the error i got.

➜  ~ scrcpy
/usr/local/share/scrcpy/scrcpy-server.jar: ...le pushed. 1.3 MB/s (19038 bytes in 0.014s)
2018-03-13 12:20:57.823 scrcpy[6894:419807] INFO: Initial texture: 540x960
ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalStateException
    at android.media.MediaCodec.native_stop(Native Method)
    at android.media.MediaCodec.stop(MediaCodec.java:1901)
    at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:69)
    at com.genymobile.scrcpy.Server.scrcpy(Server.java:21)
    at com.genymobile.scrcpy.Server.main(Server.java:70)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:251)
2018-03-13 12:20:58.428 scrcpy[6894:419909] ERROR: Could not open video stream

@ArnoldLaishram No I could unfortunately not find any solution, I tried compiling using webm instead of video/avc but that didn't work either and gave the same error, it seems replicant doesn't have a lot of the video encoders.

Windows 10 / Java 8 have the same problem with wireless. Just have this hint:

$ ./scrcpy.exe -b2M
ERROR: "adb reverse" returned with value 1
WARN: 'adb reverse' failed, fallback to 'adb forward'
INFO: Initial texture: 1920x1200
ERROR: Could not open video stream

environment

$java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

$ver
Microsoft Windows [Version 10.0.14393]

@gam2046 I'm not sure, but your error log seems to have something with https://github.com/Genymobile/scrcpy/issues/5 to do. Maybe try updating your adb / android tools.

@Necklaces emmmm , I'm using scrcpy-windows-with-deps-v1.1.zip.

It already contains the latest version of ADB

$ ./adb version
Android Debug Bridge version 1.0.39
Version 0.0.1-4500957

The same device, I try to connect through USB is working properly, but failed through the network.

The same device, I try to connect through USB is working properly, but failed through the network.

@gam2046 Please try on master branch (there was a fix for this since the last release).

@rom1v I tried compiling this project myself and connecting devices through the network ADB again. But still failed

$ scrcpy
ERROR: "adb reverse" returned with value 1
WARN: 'adb reverse' failed, fallback to 'adb forward'
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
ERROR: Could not open video stream
INFO: Initial texture: 1200x1920

Maybe it has something to do with Android version, so I tried two devices. One Android 7.0 device is all right, and the other Android 5.1.1 shows the above prompt.

Same problem here using Windows 10 and scrcpy-win64-v1.2.zip
Works on an HTC M8S Android V6.0.1
Gives this on an Acer Iconia B3-A40FHD Android V7.0 and exits.

PS D:\ScrCpy\scrcpy-win64> ./adb devices
List of devices attached
730009486815    device

PS D:\ScrCpy\scrcpy-win64> ./adb shell
acer_asgardfhd:/ $ exit
PS D:\ScrCpy\scrcpy-win64> .\scrcpy.exe
scrcpy-server.jar: 1 file pushed.
ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalStateException
        at android.media.MediaCodec.native_stop(Native Method)
        at android.media.MediaCodec.stop(MediaCodec.java:2018)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:69)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:22)
        at com.genymobile.scrcpy.Server.main(Server.java:78)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:294)
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol
ERROR: Could not open video stream
INFO: Initial texture: 1920x1200
PS D:\ScrCpy\scrcpy-win64>

I had this issue too, I have very little to do with this program until 5min ago,
But seems like this error has been very briefly looked at before in Issue #73
Using the lower resolution/bitrate with the parameters,

scrcpy -b2M -m800

Same issue with Nexus 7 on Android 6.0.1

The command scrcpy -b2M -m800 did get it working for me.

@Gmanzee commented on 4 juil. 2018 à 04:11 UTC−4:

The command scrcpy -b2M -m800 did get it working for me.

Same here it worked for me, it's a little bit blurry but at least it work 👍👍👍

I've made a batch file so when I encounter a device that don't work "normally" I use the batch file to start SCRCPY .

Regards :octocat:

Thanks for this fix

@mikhoul Maybe you could increase the definition until it fails.

scrcpy -m 1024
scrcpy -m 1280
…

I can get scrcpy -m 1650 to work but I fail at scrcpy -m 1700
Inserting -b2M doesn't effect the outcome. Even reducing to -b1M doesn't allow 1700.

scrcpy -b2M -m800

Worked for me too. I used an Ulefone Armor 3WT

Was this page helpful?
0 / 5 - 0 ratings

Related issues

qymspace picture qymspace  ·  3Comments

behzadpooldar picture behzadpooldar  ·  4Comments

cutoseo picture cutoseo  ·  4Comments

tonypachino picture tonypachino  ·  3Comments

YurieCo picture YurieCo  ·  4Comments