AVFoundation – AVAssetImageGenerator 截图
目錄
- 一.前言
- 1.AVAsset
- 2.AVAssetTrack
- 3.AVComposition / AVMutableComposition
- 4.AVMutableVideoComposition
- 5.AVMutableCompositionTrack
- 6.AVMutableVideoCompositionLayerInstruction
- 7.AVMutableVideoCompositionInstruction
- 8.AVAssetExportSession
- 二.AVAssetImageGenerator 簡介
- 1.精確時間截圖
- 2.指定截圖尺寸
- 三.AVAssetImageGenerator 截圖
- 四.猜你喜歡
零基礎 Object-C 學習路線推薦 : Object-C 學習目錄 >> Object-C 基礎
零基礎 Object-C 學習路線推薦 : Object-C 學習目錄 >> Object-C 線程
零基礎 Object-C 學習路線推薦 : Object-C 學習目錄 >> OpenGL ES
零基礎 Object-C 學習路線推薦 : Object-C 學習目錄 >> GPUImage
零基礎 Object-C 學習路線推薦 : Object-C 學習目錄 >> AVFoundation
零基礎 Object-C 學習路線推薦 : Object-C 學習目錄 >> CocoaPods
一.前言
1.AVAsset
Assets 可以來自一個文件或用戶的相冊,可以理解為多媒體資源,通過 URL 作為一個 asset 對象的標識. 這個 URL 可以是本地文件路徑或網絡流;
2.AVAssetTrack
AVAsset 包含很多軌道 **AVAssetTrack **的結合,如 audio, video, text, closed captions, subtitles…
3.AVComposition / AVMutableComposition
**使用 AVMutableComposition 類可以增刪 AVAsset 來將單個或者多個 AVAsset 集合到一起,用來合成新視頻。**除此之外,若想將集合到一起的視聽資源以自定義的方式進行播放,需要使用 AVMutableAudioMix 和 AVMutableVideoComposition 類對其中的資源進行協調管理;
4.AVMutableVideoComposition
AVFoundation 類 API 中最核心的類是 AVVideoComposition / AVMutableVideoComposition 。
AVVideoComposition / AVMutableVideoComposition 對兩個或多個視頻軌道組合在一起的方法給出了一個總體描述。它由一組時間范圍和描述組合行為的介紹內容組成。這些信息出現在組合資源內的任意時間點。
AVVideoComposition / AVMutableVideoComposition 管理所有視頻軌道,可以決定最終視頻的尺寸,裁剪需要在這里進行;
5.AVMutableCompositionTrack
將多個 AVAsset 集合到一起合成新視頻中軌道信息,有音頻軌、視頻軌等,里面可以插入各種對應的素材(畫中畫,水印等);
6.AVMutableVideoCompositionLayerInstruction
AVMutableVideoCompositionLayerInstruction 主要用于對視頻軌道中的一個視頻處理縮放、模糊、裁剪、旋轉等;
7.AVMutableVideoCompositionInstruction
表示一個指令,決定一個 timeRange 內每個軌道的狀態,每一個指令包含多個 AVMutableVideoCompositionLayerInstruction ;而 AVVideoComposition 由多個 AVVideoCompositionInstruction 構成;
AVVideoCompositionInstruction 所提供的最關鍵的一段數據是組合對象時間軸內的時間范圍信息。這一時間范圍是在某一組合形式出現時的時間范圍。要執行的組全特質是通過其 AVMutableVideoCompositionLayerInstruction 集合定義的。
8.AVAssetExportSession
AVAssetExportSession 主要用于導出視頻;
二.AVAssetImageGenerator 簡介
AVAssetImageGenerator 是用來提供視頻的縮略圖或預覽視頻的幀的類.可以用AVAsset 來初始化,例如:
+ (instancetype)assetImageGeneratorWithAsset:(AVAsset *)asset; - (instancetype)initWithAsset:(AVAsset *)asset NS_DESIGNATED_INITIALIZER;注意 NSURL 的使用:
[NSURL URLWithString:@"網絡路徑"] [NSURL fileURLWithPath:@"本地路徑"] 如果讀取的是本地文件,那么請用第二個方法,第一個會出錯,讀取不到URL.1.精確時間截圖
**生成圖片的真正時間可能在 requestedTimeToleranceBefore 和 requestedTimeToleranceAfter 之間,也可能和請求時間無關,**需要做如下設置:
跳轉閱讀全文…
CMTime 可以這么理解:CMTimeMake(a ,b)。其中,a / b 就是當前的秒數
CMTime CMTimeMake(int64_t value, // 值int32_t timescale, // 時間刻度 )四.猜你喜歡
- AVAsset 加載媒體
- AVAssetTrack 獲取視頻 音頻信息
- AVMetadataItem 獲取媒體屬性元數據
- AVAssetImageGenerator 截圖
- AVAssetImageGenerator 獲取多幀圖片
- AVAssetExportSession 裁剪/轉碼
- AVPlayer 播放視頻
- AVPlayerItem 管理資源對象
- AVPlayerLayer 顯示視頻
- AVQueuePlayer 播放多個媒體文件
- AVComposition AVMutableComposition 將多個媒體合并
- AVVideoComposition AVMutableVideoComposition 管理所有視頻軌道
未經允許不得轉載:猿說編程 ? AVFoundation – AVAssetImageGenerator 截圖
總結
以上是生活随笔為你收集整理的AVFoundation – AVAssetImageGenerator 截图的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: QtCreate由MinGW编译的项目,
- 下一篇: qt实现窗口拖动的两种思路