亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

 更新時間:2013年06月02日 17:01:18   作者:  
camera錄制的視頻的縮略圖如何獲取,想必有很多的朋友都不會吧,下面與大家分享下獲取的原理,感興趣的你可不要錯過了哈
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ù)
復(fù)制代碼 代碼如下:

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。

相關(guān)文章

最新評論