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

Device encoder crashes [OMX.Intel.hw_ve.h264] ERROR(0x80001001) #1810

Closed
tzah4748 opened this issue Oct 6, 2020 · 8 comments
Closed

Device encoder crashes [OMX.Intel.hw_ve.h264] ERROR(0x80001001) #1810

tzah4748 opened this issue Oct 6, 2020 · 8 comments
Labels

Comments

@tzah4748
Copy link

tzah4748 commented Oct 6, 2020

Environment

  • OS: Windows
  • scrcpy version: 1.16
  • installation method: Windows release
  • device model: PANASONIC FZ-A2A (Tablet)
  • Android version: Android 6.0.1

Describe the bug
Scrcpy starts and crashes after a few seconds.

adb shell screenrecord is working fine.
Tried using a smaller resolution with scrcpy -m600 or -m800, same issue.
Tried using a low bitrate of 2000000.

Attaching the logcat and media_codecs.xml that i pulled from the device.

logcat.log
media_codecs.xml -

<?xml version="1.0" encoding="utf-8" ?>
<!-- ############# BEGIN MIX-IN DEFINITIONS ############## -->
<!-- Mix-In definitions are auto-generated by mixin-update -->
<!-- ##################################################### -->
<!-- Source: device/intel/mixins/groups/codecs/configurable/media_codecs.xml -->
<!-- ##################################################### -->
<!-- Copyright (C) 2012 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!--
<!DOCTYPE MediaCodecs [
<!ELEMENT MediaCodecs (Decoders,Encoders)>
<!ELEMENT Decoders (MediaCodec*)>
<!ELEMENT Encoders (MediaCodec*)>
<!ELEMENT MediaCodec (Type*,Quirk*)>
<!ATTLIST MediaCodec name CDATA #REQUIRED>
<!ATTLIST MediaCodec type CDATA>
<!ELEMENT Type EMPTY>
<!ATTLIST Type name CDATA #REQUIRED>
<!ELEMENT Quirk EMPTY>
<!ATTLIST Quirk name CDATA #REQUIRED>
]>

There's a simple and a complex syntax to declare the availability of a
media codec:

A codec that properly follows the OpenMax spec and therefore doesn't have any
quirks and that only supports a single content type can be declared like so:

    <MediaCodec name="OMX.foo.bar" type="something/interesting" />

If a codec has quirks OR supports multiple content types, the following syntax
can be used:

    <MediaCodec name="OMX.foo.bar" >
        <Type name="something/interesting" />
        <Type name="something/else" />
        ...
        <Quirk name="requires-allocate-on-input-ports" />
        <Quirk name="requires-allocate-on-output-ports" />
        <Quirk name="output-buffers-are-unreadable" />
    </MediaCodec>

Only the three quirks included above are recognized at this point:

"requires-allocate-on-input-ports"
    must be advertised if the component does not properly support specification
    of input buffers using the OMX_UseBuffer(...) API but instead requires
    OMX_AllocateBuffer to be used.

"requires-allocate-on-output-ports"
    must be advertised if the component does not properly support specification
    of output buffers using the OMX_UseBuffer(...) API but instead requires
    OMX_AllocateBuffer to be used.

"output-buffers-are-unreadable"
    must be advertised if the emitted output buffers of a decoder component
    are not readable, i.e. use a custom format even though abusing one of
    the official OMX colorspace constants.
    Clients of such decoders will not be able to access the decoded data,
    naturally making the component much less useful. The only use for
    a component with this quirk is to render the output to the screen.
    Audio decoders MUST NOT advertise this quirk.
    Video decoders that advertise this quirk must be accompanied by a
    corresponding color space converter for thumbnail extraction,
    matching surfaceflinger support that can render the custom format to
    a texture and possibly other code, so just DON'T USE THIS QUIRK.

-->

<MediaCodecs>
    <Decoders>
        <MediaCodec name="OMX.Intel.mp3.decoder" type="audio/mpeg" />
        <MediaCodec name="OMX.Intel.amrnb.decoder" type="audio/3gpp" />
        <MediaCodec name="OMX.Intel.amrwb.decoder" type="audio/amr-wb" />
        <MediaCodec name="OMX.Intel.aac.decoder" type="audio/mp4a-latm" />
        <MediaCodec name="OMX.Intel.vorbis.decoder" type="audio/vorbis" />
        <MediaCodec name="OMX.Intel.hw_vd.h264" type="video/avc" >
            <!-- profiles and levels:  ProfileBaseline : Level51 -->
            <Limit name="size" min="64x64" max="3840x2160" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="blocks-per-second" range="1-972000" />
            <Limit name="bitrate" range="1-40000000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
        <MediaCodec name="OMX.Intel.hw_vd.h264.secure" type="video/avc">
            <!-- profiles and levels:  ProfileBaseline : Level51 -->
            <Limit name="size" min="64x64" max="3840x2160" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="blocks-per-second" range="1-972000" />
            <Limit name="bitrate" range="1-40000000" />
            <Feature name="adaptive-playback" />
            <Feature name="secure-playback" required="true" />
        </MediaCodec>
        <MediaCodec name="OMX.Intel.hw_vd.vp8" type="video/x-vnd.on2.vp8" >
            <Limit name="size" min="64x64" max="3840x2160" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="blocks-per-second" range="1-972000" />
            <Limit name="bitrate" range="1-40000000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
        <MediaCodec name="OMX.Intel.sw_vd.vp9" type="video/x-vnd.on2.vp9" >
            <Limit name="size" min="64x64" max="3840x2160" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="blocks-per-second" range="1-972000" />
            <Limit name="bitrate" range="1-40000000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
        <MediaCodec name="OMX.Intel.hw_vd.h265" type="video/hevc" >
            <Limit name="size" min="64x64" max="3840x2160" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="blocks-per-second" range="1-972000" />
            <Limit name="bitrate" range="1-10000000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
    </Decoders>

    <Encoders>
        <MediaCodec name="OMX.Intel.aac.encoder" type="audio/mp4a-latm" />
        <MediaCodec name="OMX.Intel.amrnb.encoder" type="audio/3gpp" />
        <MediaCodec name="OMX.Intel.amrwb.encoder" type="audio/amr-wb" />
        <MediaCodec name="OMX.Intel.hw_ve.h264" type="video/avc" >
            <Limit name="size" min="176x144" max="3840x2160" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="blocks-per-second" range="1-243000" />
            <Limit name="bitrate" range="1-15000000" />
        </MediaCodec>
        <MediaCodec name="OMX.Intel.hw_ve.vp8" type="video/x-vnd.on2.vp8" >
            <Limit name="size" min="176x144" max="3840x2160" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="blocks-per-second" range="1-243000" />
            <Limit name="bitrate" range="1-15000000" />
        </MediaCodec>
    </Encoders>
    <Include href="media_codecs_google_video.xml" />
    <Include href="media_codecs_google_audio.xml" />
    <Settings>
        <Setting name="max-video-encoder-input-buffers" value="9" />
    </Settings>
</MediaCodecs>
<!-- ############## END MIX-IN DEFINITIONS ############### -->
@rom1v
Copy link
Collaborator

rom1v commented Oct 6, 2020

Thank you for your report.

Could you please list the codecs as reported by CheckVideoCodecs? (refs #55 (comment))

@tzah4748
Copy link
Author

tzah4748 commented Oct 6, 2020

Yes i will get you the list soon, thanks for the quick answer.

@tzah4748
Copy link
Author

tzah4748 commented Oct 8, 2020

Hi @rom1v - attached the output
debug.zip

EDIT: I've noticed that the device has both Intel and google encoders for h264 but from the logcat i can see the device is trying to use the Intel encoder.
Can we force it to use the other one? (google's) if this can be done it might solve the issue

video/avc -> OMX.Intel.hw_ve.h264

=== OMX.Intel.aac.encoder ===
Supported types: [audio/mp4a-latm]

=== OMX.Intel.amrnb.encoder ===
Supported types: [audio/3gpp]

=== OMX.Intel.amrwb.encoder ===
Supported types: [audio/amr-wb]

=== OMX.Intel.hw_ve.h264 ===
Supported types: [video/avc]
video/avc capabilities:
        default format: {mime=video/avc, bitrate-mode=1}
        profile levels: [0x1/0x8000, 0x2/0x8000, 0x4/0x8000, 0x8/0x8000]
        color formats: [2135033992, 21, 2130708361]
        bitrate: [1, 15000000]
        framerate: [0, 960]
        widths: [176, 3840]
        heights: [144, 2160]
        w,h alignment: 2,2
TEST OK

=== OMX.Intel.hw_ve.vp8 ===
Supported types: [video/x-vnd.on2.vp8]

=== OMX.google.h263.encoder ===
Supported types: [video/3gpp]

=== OMX.google.h264.encoder ===
Supported types: [video/avc]
video/avc capabilities:
        default format: {mime=video/avc, bitrate-mode=1}
        profile levels: [0x1/0x1, 0x1/0x2, 0x1/0x4, 0x1/0x8, 0x1/0x10, 0x1/0x20, 0x1/0x40, 0x1/0x80, 0x1/0x100, 0x1/0x200, 0x1/0x400, 0x1/0x800, 0x1/0x1000, 0x2/0x1, 0x2/0x2, 0x2/0x4, 0x2/0x8, 0x2/0x10, 0x2/0x20, 0x2/0x40, 0x2/0x80, 0x2/0x100, 0x2/0x200, 0x2/0x400, 0x2/0x800, 0x2/0x1000]
        color formats: [2135033992, 19, 21, 2130708361]
        bitrate: [1, 12000000]
        framerate: [0, 960]
        widths: [16, 1920]
        heights: [16, 1088]
        w,h alignment: 2,2
TEST OK

=== OMX.google.mpeg4.encoder ===
Supported types: [video/mp4v-es]

=== OMX.google.vp8.encoder ===
Supported types: [video/x-vnd.on2.vp8]

=== OMX.google.aac.encoder ===
Supported types: [audio/mp4a-latm]

=== OMX.google.amrnb.encoder ===
Supported types: [audio/3gpp]

=== OMX.google.amrwb.encoder ===
Supported types: [audio/amr-wb]

=== OMX.google.flac.encoder ===
Supported types: [audio/flac]

@rom1v
Copy link
Collaborator

rom1v commented Oct 8, 2020

OK, so there are two H.264 encoder, but the first one is not working.

I guess I should add a command-line option to force a specific encoder…

@rom1v rom1v added the codec label Oct 8, 2020
@tzah4748
Copy link
Author

tzah4748 commented Oct 8, 2020

I've made a quick test by building the server on my own.
I've added a force creation of the MediaCodec by name with the google encoder, the device worked fine, played with it for a good few minutes and it didn't crash anymore.

image

So we can say for sure this feature of forcing encoder is needed and will solve the issue.

@tzah4748 tzah4748 closed this as completed Oct 8, 2020
@rom1v rom1v reopened this Oct 8, 2020
@rom1v
Copy link
Collaborator

rom1v commented Oct 8, 2020

Do you want to work on this feature?

@tzah4748
Copy link
Author

tzah4748 commented Oct 8, 2020

OK i will do it 👍 and submit a PR

rom1v pushed a commit that referenced this issue Nov 8, 2020
Some devices have more than one encoder, some encoders may cause issues
or crash. With this option we can specify which encoder we want the
device to use.

PR #1827 <#1827>
Fixes #1810 <#1810>

Signed-off-by: Romain Vimont <[email protected]>
rom1v pushed a commit that referenced this issue Nov 8, 2020
Some devices have more than one encoder, and some encoders may cause
issues or crash. With this option we can specify which encoder we want
the device to use.

PR #1827 <#1827>
Fixes #1810 <#1810>

Signed-off-by: Romain Vimont <[email protected]>
@rom1v
Copy link
Collaborator

rom1v commented Nov 8, 2020

Fixed by #1827.

@rom1v rom1v closed this as completed Nov 8, 2020
jellopuddingstick added a commit to jellopuddingstick/scrcpy that referenced this issue Jan 23, 2021
scrcpy v1.17

Changes since v1.16:
 - Fix errors on Android 11 (Genymobile#1468)
 - Add --encoder option (Genymobile#1810, Genymobile#1827)
 - Add --forward-all-clicks option (Genymobile#1302, Genymobile#1613)
 - Add --legacy-paste option (Genymobile#1750, Genymobile#1771)
 - Workaround screen off/on issue on exit (Genymobile#1670)
 - Rework console/noconsole versions on Windows (Genymobile#1875, Genymobile#1988)
 - Terminate server properly without killing it on close (Genymobile#1992)
 - List available shortcut keys on error (Genymobile#1681)
 - Upgrade platform-tools to 30.0.5 (adb) in Windows releases
 - Upgrade SDL to 2.0.14 in Windows releases
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

2 participants