【问题标题】:Recording selected area of screen in android在android中记录屏幕的选定区域
【发布时间】:2019-07-13 18:04:42
【问题描述】:

我正在尝试实现屏幕录像机。我关注了grafika。只需将 Surface 从 encoder.getInputSurface() 提供给 VirtualDisplay 就可以了。现在我的任务是对屏幕的某个部分进行编码。所以,我试图使用 SurfaceTexture 修改编码器的输入 Surface(我认为这是正确的方法)。但我无法使用创建的表面来记录屏幕,当我将此表面传递给 VirtualDisplay 时,我没有得到任何回调。 我也尝试使用 TextureMovieEncoder(来自 grafika)进行录制,但可能我不知道正确的方法。

我试图通过以下有用的链接来理解。 How does an output surface of a Decoder is passed to an input surface of an Encoder?

Android: Is it possible to create a SurfaceTexture without a SurfaceView?

我确信 grafika 是一个很棒的教程,但我卡住了。

请提出解决方案或其他可行的方法。我现在被困了好几天。

【问题讨论】:

    标签: android opengl-es grafika android-mediacodec


    【解决方案1】:

    我认为正确的方法如下:

    1. 使用 oes 纹理创建 SurfaceTexture。

    2. 将 VirtualDisplay 连接到步骤 1 中创建的表面纹理,因此帧将转到 oes 纹理

    3. 在surfacetexture上注册onFrameAvailable监听器,就会不断得到回调

    4. 将 oes 纹理中的帧渲染到编码器的输入表面。

    关键过程是第4步。在渲染过程中,可以通过修改纹理坐标来裁剪帧。

    下面有一个裁剪示例: Crop video before encoding with MediaCodec for Grafika's "Continuous Capture" Activity

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多