【问题标题】:Clip the video to fullly fill the screen in Android Auto在 Android Auto 中剪辑视频以完全填满屏幕
【发布时间】:2021-12-28 20:24:40
【问题描述】:

现在,我正在开发我们自己的 Android Auto 项目。我遇到了一个问题。 我添加了 3 个支持的 VideoConfiguration。 (1920 X 1080、1280 X 720、800 X 480) 我们的车载屏幕尺寸为 1920 X 720。 在车上启动我的应用程序后,我注意到手机告诉我们手机(或 MD)输出的视频是 1920 X 1080。我还将查看区域设置为 1920 X 720,或者换句话说,内容区域是1920 X 720。 终于放出了投影视频,可惜视频被强行拉伸了。所有这些图标,文字都变形了,好像我的配置没用一样。 我的问题是,如何调整我的参数,以便正确显示 MD 的投影内容。

我问了谷歌的服务台,他们告诉我将边距分别设置在顶部和底部 180。 但我试过了,如下所示,

    VideoFrameRateType frameRate = (fps == 30) ? VideoFrameRateType.VIDEO_FPS_30 : VideoFrameRateType.VIDEO_FPS_60;
    Protos.Insets.Builder insetsBuilder = Protos.Insets.newBuilder().setTop(180).setBottom(180);
    UiConfig.Builder uiBuilder = UiConfig.newBuilder().setMargins(insetsBuilder);


    VideoConfiguration.Builder builder = VideoConfiguration.newBuilder()

// .setUiConfig(uiBuilder) .setCodecResolution(codecResolution) .setFrameRate(帧率) .setWidthMargin(0) .setHeightMargin(360) .setDensity(213) .setRealDensity(170) .setVideoCodecType(MediaCodecType.MEDIA_CODEC_VIDEO_H264_BP) .setDecoderAdditionalDepth(decoderAdditionalDepth) .setViewingDistance(查看距离) .setPixelAspectRatioE4(Math.round(pixelAspectRatio * 1e4f));

我尝试设置heightMargin,或者添加UiConfig的setTop(180).setBottom(180),都解决不了问题。

或者,我能做些什么吗?我以编程方式创建 MediaFormat format = MediaFormat.createVideoFormat?

【问题讨论】:

    标签: android-auto


    【解决方案1】:

    我想我已经自己把事情整理好了。 首先,我们需要调整布局属性,从 match_parent 到 1920px & 1080px。

    其次,在我们创建 VedioConfiguration 之前,我们应该新建 UiConfig 并设置其顶部和底部以匹配您的内容区域。

    【讨论】:

    • 您好,我们尝试了您的布局调整和使用边距更新 UiConfig 的方法,但这对我们没有帮助。我们面临同样的问题。是否可以详细说明您的解决方案,如果您提供代码 sn-p 会很棒。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-19
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多