Skip to content
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

ERROR: Could not open video stream #1

Closed
Necklaces opened this issue Mar 8, 2018 · 19 comments
Closed

ERROR: Could not open video stream #1

Necklaces opened this issue Mar 8, 2018 · 19 comments
Labels

Comments

@Necklaces
Copy link

Necklaces commented Mar 8, 2018

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

@rom1v
Copy link
Collaborator

rom1v commented Mar 9, 2018

I think Replicant may be the offender here.

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

@yesi
Copy link

yesi commented Mar 9, 2018

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

:-(

@frostworx
Copy link

frostworx commented Mar 10, 2018

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

@frostworx
Copy link

while searching for the "Invalid return value 0 for stream protocol" crash, I found this mpv issue:
mpv-player/mpv#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.

@arnoldlaishram
Copy link

arnoldlaishram commented Mar 13, 2018

@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

@Necklaces
Copy link
Author

@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.

@Lua12138
Copy link

Lua12138 commented May 3, 2018

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]

@Necklaces
Copy link
Author

@gam2046 I'm not sure, but your error log seems to have something with #5 to do. Maybe try updating your adb / android tools.

@Lua12138
Copy link

Lua12138 commented May 3, 2018

@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.

@rom1v
Copy link
Collaborator

rom1v commented May 3, 2018

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).

@Lua12138
Copy link

Lua12138 commented May 10, 2018

@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.

@Gmanzee
Copy link

Gmanzee commented May 31, 2018

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>

@Owlkaline
Copy link

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

@alfeg
Copy link

alfeg commented Jul 4, 2018

Same issue with Nexus 7 on Android 6.0.1

@Gmanzee
Copy link

Gmanzee commented Jul 4, 2018

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

@mikhoul
Copy link

mikhoul commented Jul 18, 2018

@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

@rom1v
Copy link
Collaborator

rom1v commented Jul 18, 2018

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

scrcpy -m 1024
scrcpy -m 1280
…

@Gmanzee
Copy link

Gmanzee commented Jul 19, 2018

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.

@rom1v rom1v closed this as completed Sep 24, 2018
@vasu97 vasu97 mentioned this issue Jan 31, 2019
NickStemerdink pushed a commit to NickStemerdink/scrcpy that referenced this issue May 30, 2019
Fix the error case by flyme nightMode.
issue Genymobile#1
NickStemerdink pushed a commit to NickStemerdink/scrcpy that referenced this issue May 30, 2019
Fix the error case by flyme nightMode.
issue Genymobile#1
@RogerioDoCarmo
Copy link

scrcpy -b2M -m800

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

rom1v added a commit that referenced this issue Oct 27, 2021
On Linux, socket functions are unblocked by shutdown(), but on Windows
they are unblocked by closesocket().

Expose net_interrupt() and net_close() to abstract these differences:
 - net_interrupt() calls shutdown() on Linux and closesocket() on
   Windows (if not already called);
 - net_close() calls close() on Linux and closesocket() on Windows (if
   not already called).

This simplifies the server code, and prevents a data race on close
(reported by TSAN) on Linux (but does not fix it on Windows):

    WARNING: ThreadSanitizer: data race (pid=836124)
      Write of size 8 at 0x7ba0000000d0 by main thread:
        #0 close ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1690 (libtsan.so.0+0x359d8)
        #1 net_close ../app/src/util/net.c:211 (scrcpy+0x1c76b)
        #2 close_socket ../app/src/server.c:330 (scrcpy+0x19442)
        #3 server_stop ../app/src/server.c:522 (scrcpy+0x19e33)
        #4 scrcpy ../app/src/scrcpy.c:532 (scrcpy+0x156fc)
        #5 main ../app/src/main.c:92 (scrcpy+0x622a)

      Previous read of size 8 at 0x7ba0000000d0 by thread T6:
        #0 recv ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:6603 (libtsan.so.0+0x4f4a6)
        #1 net_recv ../app/src/util/net.c:167 (scrcpy+0x1c5a7)
        #2 run_receiver ../app/src/receiver.c:76 (scrcpy+0x12819)
        #3 <null> <null> (libSDL2-2.0.so.0+0x84f40)
rom1v added a commit that referenced this issue Oct 27, 2021
On Linux, socket functions are unblocked by shutdown(), but on Windows
they are unblocked by closesocket().

Expose net_interrupt() and net_close() to abstract these differences:
 - net_interrupt() calls shutdown() on Linux and closesocket() on
   Windows (if not already called);
 - net_close() calls close() on Linux and closesocket() on Windows (if
   not already called).

This simplifies the server code, and prevents a data race on close
(reported by TSAN) on Linux (but does not fix it on Windows):

    WARNING: ThreadSanitizer: data race (pid=836124)
      Write of size 8 at 0x7ba0000000d0 by main thread:
        #0 close ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1690 (libtsan.so.0+0x359d8)
        #1 net_close ../app/src/util/net.c:211 (scrcpy+0x1c76b)
        #2 close_socket ../app/src/server.c:330 (scrcpy+0x19442)
        #3 server_stop ../app/src/server.c:522 (scrcpy+0x19e33)
        #4 scrcpy ../app/src/scrcpy.c:532 (scrcpy+0x156fc)
        #5 main ../app/src/main.c:92 (scrcpy+0x622a)

      Previous read of size 8 at 0x7ba0000000d0 by thread T6:
        #0 recv ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:6603 (libtsan.so.0+0x4f4a6)
        #1 net_recv ../app/src/util/net.c:167 (scrcpy+0x1c5a7)
        #2 run_receiver ../app/src/receiver.c:76 (scrcpy+0x12819)
        #3 <null> <null> (libSDL2-2.0.so.0+0x84f40)
rom1v added a commit that referenced this issue Jan 27, 2022
The server needs to interrupt the sockets on stop, but it must not close
them while other threads may attempt to read from or write to them.

In particular, the video_socket is read by the stream thread, and the
control_socket is written by the controller and read by receiver.

Therefore, close the socket only on sc_server_destroy(), which is called
after all other threads are joined.

Reported by TSAN on close:

    WARNING: ThreadSanitizer: data race (pid=3287612)
      Write of size 8 at 0x7ba000000080 by thread T1:
        #0 close ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1690 (libtsan.so.0+0x359d8)
        #1 net_close ../app/src/util/net.c:280 (scrcpy+0x23643)
        #2 run_server ../app/src/server.c:772 (scrcpy+0x20047)
        #3 <null> <null> (libSDL2-2.0.so.0+0x905a0)

      Previous read of size 8 at 0x7ba000000080 by thread T16:
        #0 recv ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:6603 (libtsan.so.0+0x4f4a6)
        #1 net_recv_all ../app/src/util/net.c:228 (scrcpy+0x234a9)
        #2 stream_recv_packet ../app/src/stream.c:33 (scrcpy+0x2045c)
        #3 run_stream ../app/src/stream.c:228 (scrcpy+0x21169)
        #4 <null> <null> (libSDL2-2.0.so.0+0x905a0)

Refs ddb9396
@meroz92 meroz92 mentioned this issue Jun 25, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests