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

Fails to initialize on Android Wear smartwatch #82

Closed
parkerlreed opened this issue Mar 19, 2018 · 19 comments
Closed

Fails to initialize on Android Wear smartwatch #82

parkerlreed opened this issue Mar 19, 2018 · 19 comments

Comments

@parkerlreed
Copy link

[parker@gpdpocket x]$ scrcpy 
/usr/local/share/scrcpy/scrcpy-server.jar: 1 file pushed. 2.5 MB/s (19334 bytes in 0.007s)
ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalArgumentException: Failed to initialize video/avc, error 0xfffffffe
        at android.media.MediaCodec.native_setup(Native Method)
        at android.media.MediaCodec.<init>(MediaCodec.java:1776)
        at android.media.MediaCodec.createEncoderByType(MediaCodec.java:1742)
        at com.genymobile.scrcpy.ScreenEncoder.createCodec(ScreenEncoder.java:115)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:57)
        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:262)
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: 320x320

Asus Zenwatch 2 on Android Wear 2.0.

@rom1v
Copy link
Collaborator

rom1v commented Mar 19, 2018

I don't have a smart watch, but the documentation of createEncoderByType() says:

Note: It is preferred to use findEncoderForFormat(MediaFormat) and createByCodecName(String) to ensure that the resulting codec can handle a given format.

Maybe you could try replacing this call as suggested. Not sure it will work better.

@parkerlreed
Copy link
Author

Is there a way to query what it supports via adb?

@parkerlreed
Copy link
Author

I got my environment setup so I can build the server. What exactly would I change in that call to test it out?

@parkerlreed
Copy link
Author

I just realized the watch has NO encoders. Only decoders.
screen1

That's probably the issue.

@rom1v rom1v added the codec label Mar 19, 2018
@rom1v rom1v closed this as completed Mar 22, 2018
@parkerlreed
Copy link
Author

Thanks, was going to close it out myself as I assumed there wasn't really anything that could be done for it.

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2018

Maybe you could test using screenrecord:

adb shell screenrecord /sdcard/file.mp4

@elig0n
Copy link

elig0n commented Mar 26, 2018

@parkerlreed how does one get to that codec information on android please ?

@parkerlreed
Copy link
Author

parkerlreed commented Mar 26, 2018

@elig0n Just an application that shows it. At the time I just found a random application online but it seems there's one on the store https://play.google.com/store/apps/details?id=net.tyniw.mediacodecinfo.application

@rom1v
Copy link
Collaborator

rom1v commented Mar 26, 2018

@parkerlreed Does screenrecord work for you (like @elig0n)?

@parkerlreed
Copy link
Author

@rom1v I seem to have my charger but not my watch... I'll see if I can dig it out and give it a test.

@rom1v
Copy link
Collaborator

rom1v commented Mar 27, 2018

@parkerlreed I just created a project to give more infos about video codecs available: CheckVideoCodecs.

Please post its results for your watch.

@kaushiknadig
Copy link

Hi,
I faced the same error above. and @rom1v I tried screen record. It says the following.

ERROR: unable to create video/avc codec instance
WARNING: failed at 454x454, retrying at 1280x720
ERROR: unable to create video/avc codec instance

Seems like android wear watches does not have encoders at all.

@rom1v rom1v added the android4 label Sep 4, 2018
@parkerlreed
Copy link
Author

This was never Android 4. Most watches were on Marshmallow at the time (and I'm hitting the same on Nougat)

Also sorry for the late response. Just circled back around to this. I am unable to build the CheckVideoCodecs

[parker@stealth CheckVideoCodecs]$ make run 
./gradlew assembleDebug

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
make: *** [Makefile:8: build] Error 1

@andreluigo
Copy link

I am facing the same issue with my Amazfit Stratos...
I lost touch function and need to confirm the code on the screen to pair the watch again but i am getting these erros:

C:\Windows\system32>"D:\Downloads\Compressed\scrcpy-win64-v1.9\scrcpy-win64\scrcpy.exe"
D:\Downloads\Compressed\scrcpy-win64-v1.9\scrcpy-win64\scr...erver.jar: 1 file pushed. 2.0 MB/s (22470 bytes in 0.011s)
INFO: Initial texture: 320x296
ERROR: Could not open video stream

Other times:

C:\Windows\system32>"D:\Downloads\Compressed\scrcpy-win64-v1.9\scrcpy-win64\scrcpy.exe"
D:\Downloads\Compressed\scrcpy-win64-v1.9\scrcpy-win64\scr...erver.jar: 1 file pushed. 3.2 MB/s (22470 bytes in 0.007s)
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalArgumentException: Failed to initialize video/avc, error 0xfffffffe
at android.media.MediaCodec.native_setup(Native Method)
at android.media.MediaCodec.(MediaCodec.java:486)
at android.media.MediaCodec.createEncoderByType(MediaCodec.java:456)
at com.genymobile.scrcpy.ScreenEncoder.createCodec(ScreenEncoder.java:137)
at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:62)
at com.genymobile.scrcpy.Server.scrcpy(Server.java:32)
at com.genymobile.scrcpy.Server.main(Server.java:133)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:249)
ERROR: Could not open video stream
INFO: Initial texture: 320x296

Some can help me please? Tested at Galaxy S8 and worked like a charm.

@rom1v
Copy link
Collaborator

rom1v commented Aug 3, 2019

@andreluigo Is it Android 4?

Anyway, it seems "smart watches" don't have a H.264 encoder.

@andreluigo
Copy link

@andreluigo Is it Android 4?

No. It's newer.
Actually O.S. of Amazfit is Watch 2.0 (based on Android, i guess).

@odbol
Copy link

odbol commented Oct 27, 2020

I wonder if this could be fixed by using "video/raw" encoding instead of "video/avc"? Wear does support raw video encoding, and ffmpeg can convert it: https://developer.android.com/training/wearables/apps/debugging?hl=en#screenrecord

@msugakov
Copy link

This issue seems closed but I'm failing to find a solution. What's the way to make it work with Wear OS?

@parkerlreed
Copy link
Author

There's nothing special. You just need a watch that is new enough to support it (hardware video encoding). Works right away on my Galaxy Watch4 Classic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants