国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

camera錄制視頻的縮略圖獲取原理心得分享

2020-04-11 12:17:03
字體:
供稿:網(wǎng)友
1、在thumbnail.java文件里通過調(diào)用bitmap = retriever.getFrameAtTime(-1);
這句代碼得到bitmap,

2、那么這句代碼在MediaMetadataRetriever.java 中調(diào)用
getFrameAtTime(timeUs, OPTION_CLOSEST_SYNC)這句代碼:
解釋一下timeUs,和OPTION_CLOSEST_SYNC這2個變量的含義
timeUs The time position where the frame will be retrieved.
* When retrieving the frame at the given time position, there is no
* guarentee 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

3.由于timeUs等于-1,那么在stagefrightMetadataRetriver.cpp中通過
extractVideoFrameWithCodecFlags()函數(shù)
復制代碼 代碼如下:

if (frameTimeUs < 0) {
if (!trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)
|| thumbNailTime < 0) {
thumbNailTime = 0;
}
options.setSeekTo(thumbNailTime, mode);
}else{
...................
}

取得thumbnailTime,
thumbnailTime是取同步幀中最大一幀數(shù)據(jù),即有可能不是視頻文件的第一個I幀。

4.extractVideoFrameWithCodecFlags()函數(shù)中,接著第3條,然后調(diào)用err = decoder->read(&buffer, &options);這句代碼,其options->seekMode為SEEK_CLOSEST_SYNC這個值

5.如果video codec是mpeg4,則調(diào)用MPEG4Extractor.cpp中的read()的函數(shù),
根據(jù)前面thumnailtime,找到此時間點的vidoe frame index,然后通過 video frame index,再找臨近的同步幀(即I幀)

6.SampleTable.cpp中findSyncSampleNear()函數(shù)中,找臨近同步幀,
視頻文件中會存有所有的同步幀,這個同步幀也有可能是這個同步幀數(shù)組中第一個值,也有可能在第5步中得到的video frame index,也有可能位于2個同步幀之間,那么我們通過計算找到這2個同步幀最靠近video frame index的一個同步幀

7.通過上述步驟,找到同步幀,那么根據(jù)這個同步幀生成thumbnail的bitmap。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 象山县| 富源县| 江城| 兴安县| 海安县| 扎鲁特旗| 丹东市| 金昌市| 长兴县| 西安市| 新竹市| 阜南县| 凌海市| 靖远县| 通河县| 威信县| 门头沟区| 滦平县| 东至县| 宝山区| 扎赉特旗| 巴南区| 宜宾市| 买车| 阿拉善右旗| 三江| 延庆县| 福贡县| 沙河市| 汉川市| 江华| 梨树县| 福州市| 阳信县| 乌恰县| 达日县| 肥西县| 安阳市| 三亚市| 大安市| 虹口区|