Android Camera缩率图所成的图像不是录像播放的第一帧

56 篇文章 0 订阅
2 篇文章 0 订阅

修改方法如下:
vendor/mediatek/proprietary/packages/apps/Camera2/common/src/com/mediatek/camera/common/utils/BitmapCreator.java

-            bitmap = retriever.getFrameAtTime(-1);
+            bitmap = retriever.getFrameAtTime(0);

getFrameAtTime 这个方法的参数代表啥意思?

/**
 * This method is similar to {@link #getFrameAtTime(long, int, BitmapParams)}
 * except that the device will choose the actual {@link Bitmap.Config} to use.
 *
 * @param timeUs The time position where the frame will be retrieved.
 * When retrieving the frame at the given time position, there is no
 * guarantee that the data source has a frame located at the position.
 * When this happens, a frame nearby will be returned. If timeUs is
 * negative, time position and option will ignored, and any frame
 * that the implementation considers as representative may be returned.
 *
 * @param option a hint on how the frame is found. Use
 * {@link #OPTION_PREVIOUS_SYNC} if one wants to retrieve a sync frame
 * that has a timestamp earlier than or the same as timeUs. Use
 * {@link #OPTION_NEXT_SYNC} if one wants to retrieve a sync frame
 * that has a timestamp later than or the same as timeUs. Use
 * {@link #OPTION_CLOSEST_SYNC} if one wants to retrieve a sync frame
 * that has a timestamp closest to or the same as timeUs. Use
 * {@link #OPTION_CLOSEST} if one wants to retrieve a frame that may
 * or may not be a sync frame but is closest to or the same as timeUs.
 * {@link #OPTION_CLOSEST} often has larger performance overhead compared
 * to the other options if there is no sync frame located at timeUs.
 *
 * @return A Bitmap containing a representative video frame, which can be null,
 *         if such a frame cannot be retrieved. {@link Bitmap#getConfig()} can
 *         be used to query the actual {@link Bitmap.Config}.
 *
 * @see #getFrameAtTime(long, int, BitmapParams)
 */
public @Nullable Bitmap getFrameAtTime(long timeUs, @Option int option) {
    if (option < OPTION_PREVIOUS_SYNC ||
        option > OPTION_CLOSEST) {
        throw new IllegalArgumentException("Unsupported option: " + option);
    }

    return _getFrameAtTime(timeUs, option, -1 /*dst_width*/, -1 /*dst_height*/, null);
}
@param timeUs The time position where the frame will be retrieved.
When retrieving the frame at the given time position, there is no
guarantee that the data source has a frame located at the position.
When this happens, a frame nearby will be returned. If timeUs is
negative, time position and option will ignored, and any frame
that the implementation considers as representative may be returned.

从上面这段注释中可以看出,如果 timeUs 参数是负数,time positionoption 参数会被忽略,可能返回可以代表这个视频的任何帧
如果 timeUs 是非负数,就优先返回 timeUs 所在帧,如果找不到就找附近的帧。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值