修改方法如下:
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 position
和 option
参数会被忽略,可能返回可以代表这个视频的任何帧
如果 timeUs
是非负数,就优先返回 timeUs
所在帧,如果找不到就找附近的帧。