最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2013年06月02日 17:01:18   作者:  
camera錄制的視頻的縮略圖如何獲取,想必有很多的朋友都不會吧,下面與大家分享下獲取的原理,感興趣的你可不要錯過了哈
1、在thumbnail.java文件里通過調用bitmap = retriever.getFrameAtTime(-1);
這句代碼得到bitmap,

2、那么這句代碼在MediaMetadataRetriever.java 中調用
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()函數
復制代碼 代碼如下:

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

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

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

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

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

7.通過上述步驟,找到同步幀,那么根據這個同步幀生成thumbnail的bitmap。

相關文章

最新評論

铜鼓县| 安丘市| 通渭县| 疏附县| 乐至县| 肥乡县| 古交市| 鄂托克前旗| 上虞市| 内江市| 红原县| 根河市| 新昌县| 长阳| 云南省| 麻江县| 武城县| 凤翔县| 禹州市| 多伦县| 绿春县| 宜春市| 葵青区| 当雄县| 东阳市| 墨竹工卡县| 鲁甸县| 东辽县| 宜章县| 教育| 和政县| 巴塘县| 西青区| 福鼎市| 延长县| 嵊州市| 洛阳市| 芮城县| 德清县| 邓州市| 渝中区|