DWGIFManager Class Reference

Inherits from NSObject
Declared in DWGIFManager.h
DWGIFManager.m

Overview

注释: 因为m3u8格式 无法通过AVURLAsset 截取视频流, 所以对m3u8的视频格式使用AVPlayerItemVideoOutput 截图,来生成GIF

  completeBlock

  • 制作完成GIF回调
@property (nonatomic, copy) CompleteBlock completeBlock

Discussion

  • 制作完成GIF回调

Declared In

DWGIFManager.h

  quality

  • 生成GIF质量
@property (nonatomic, assign) GIFQuality quality

Discussion

  • 生成GIF质量

Declared In

DWGIFManager.h

  loopCount

  • GIF播放的次数 0无限循环
@property (nonatomic, assign) NSInteger loopCount

Discussion

  • GIF播放的次数 0无限循环

Declared In

DWGIFManager.h

  isRecording

  • 是否正在录制gif
@property (nonatomic, readonly) BOOL isRecording

Discussion

  • 是否正在录制gif

Declared In

DWGIFManager.h

– associationWithUrl:CurrentPlayer:AndUseM3U8Method:

  • 关联播放器,startRecordingGif录制开始前调用 !!!在每次startRecordingGif前,都要调用此方法
- (void)associationWithUrl:(NSURL *)playUrl CurrentPlayer:(AVPlayer *)currentPlayer AndUseM3U8Method:(BOOL)m3u8Method

Discussion

  • 关联播放器,startRecordingGif录制开始前调用 !!!在每次startRecordingGif前,都要调用此方法

  • @param playUrl 播放路径

  • @param currentPlayer 当前播放player
  • @param m3u8Method 为YES,会强制使用m3u8视频格式截取GIF方式,一般设置为NO即可

Declared In

DWGIFManager.h

– startRecordingGif

  • 开始录制gif
- (void)startRecordingGif

Discussion

  • 开始录制gif

Declared In

DWGIFManager.h

– endRecordingGif

  • 结束录制gif 如果视频播放完成,内部会自动调用此方法,完成GIF回调
- (void)endRecordingGif

Discussion

  • 结束录制gif 如果视频播放完成,内部会自动调用此方法,完成GIF回调

Declared In

DWGIFManager.h

– cancelRecordGif

  • 取消录制gif
- (void)cancelRecordGif

Discussion

  • 取消录制gif

Declared In

DWGIFManager.h

– interceptVideoAndVideoUrl:withOutPath:outputFileType:range:intercept:

视频的URL

- (void)interceptVideoAndVideoUrl:(NSURL *)videoUrl withOutPath:(NSString *)outPath outputFileType:(NSString *)outputFileType range:(NSRange)videoRange intercept:(InterceptBlock)interceptBlock

Parameters

videoUrl

视频的URL

outPath

输出路径

outputFileType

输出视频格式

videoRange

截取视频的范围

completeBlock

视频截取的回调

Declared In

DWGIFManager.h

– getMediaDurationWithMediaUrl:

URL字符串

- (CGFloat)getMediaDurationWithMediaUrl:(NSString *)mediaUrlStr

Parameters

mediaUrlStr

URL字符串

Return Value

返回视频时长

Declared In

DWGIFManager.h

– createGIFfromURL:loopCount:delayTime:gifImagePath:complete:

生成GIF图片

- (void)createGIFfromURL:(NSURL *)videoURL loopCount:(int)loopCount delayTime:(CGFloat)time gifImagePath:(NSString *)imagePath complete:(CompleteBlock)completeBlock

Parameters

videoURL

视频的路径URL

loopCount

播放次数

time

每帧的时间间隔 默认0.25s

imagePath

存放GIF图片的文件路径

completeBlock

完成的回调

Discussion

生成GIF图片

Declared In

DWGIFManager.h

– createGIFfromURL:withFrameCount:delayTime:loopCount:gifImagePath:complete:

生成GIF图片

- (void)createGIFfromURL:(NSURL *)videoURL withFrameCount:(int)frameCount delayTime:(CGFloat)time loopCount:(int)loopCount gifImagePath:(NSString *)imagePath complete:(CompleteBlock)completeBlock

Parameters

videoURL

视频的路径URL

frameCount

视频的总时长乘以固定数值 如:视频总时长*4

time

每帧的时间间隔

loopCount

播放次数

imagePath

存放GIF图片的文件路径

completeBlock

完成的回调

Discussion

生成GIF图片

Declared In

DWGIFManager.h