国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 宜黄县| 长葛市| 岳阳市| 古田县| 舞阳县| 柘城县| 河间市| 华安县| 大同县| 东台市| 新干县| 烟台市| 孟州市| 望奎县| 卓尼县| 宝兴县| 长葛市| 揭东县| 土默特右旗| 武冈市| 奉贤区| 晋江市| 江山市| 达州市| 区。| 昌平区| 新平| 应用必备| 濮阳县| 土默特右旗| 三门峡市| 青浦区| 雷波县| 武宣县| 大丰市| 洛隆县| 井陉县| 承德县| 永昌县| 松溪县| 长葛市|