WCLRecordEncoder.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // WCLRecordEncoder.h
  3. // WCL
  4. //
  5. // **************************************************
  6. // * _____ *
  7. // * __ _ __ ___ \ / *
  8. // * \ \/ \/ / / __\ / / *
  9. // * \ _ / | (__ / / *
  10. // * \/ \/ \___/ / /__ *
  11. // * /_____/ *
  12. // * *
  13. // **************************************************
  14. // Github :https://github.com/631106979
  15. // HomePage:https://imwcl.com
  16. // CSDN :http://blog.csdn.net/wang631106979
  17. //
  18. // Created by 王崇磊 on 16/9/14.
  19. // Copyright © 2016年 王崇磊. All rights reserved.
  20. //
  21. // @class WCLRecordEncoder
  22. // @abstract 视频编码类
  23. // @discussion 视频编码类
  24. //
  25. #import <Foundation/Foundation.h>
  26. #import <AVFoundation/AVFoundation.h>
  27. /**
  28. * 写入并编码视频的的类
  29. */
  30. @interface WCLRecordEncoder : NSObject
  31. @property (nonatomic, readonly) NSString *path;
  32. @property (nonatomic, strong) AVAssetWriter *writer;//媒体写入对象
  33. /**
  34. * WCLRecordEncoder遍历构造器的
  35. *
  36. * @param path 媒体存发路径
  37. * @param cy 视频分辨率的高
  38. * @param cx 视频分辨率的宽
  39. * @param ch 音频通道
  40. * @param rate 音频的采样比率
  41. *
  42. * @return WCLRecordEncoder的实体
  43. */
  44. + (WCLRecordEncoder*)encoderForPath:(NSString*)path Height:(NSInteger)cy width:(NSInteger)cx channels: (int)ch samples:(Float64)rate;
  45. /**
  46. * 初始化方法
  47. *
  48. * @param path 媒体存发路径
  49. * @param cy 视频分辨率的高
  50. * @param cx 视频分辨率的宽
  51. * @param ch 音频通道
  52. * @param rate 音频的采样率
  53. *
  54. * @return WCLRecordEncoder的实体
  55. */
  56. - (instancetype)initPath:(NSString*)path Height:(NSInteger)cy width:(NSInteger)cx channels: (int)ch samples:(Float64)rate;
  57. /**
  58. * 完成视频录制时调用
  59. *
  60. * @param handler 完成的回掉block
  61. */
  62. - (void)finishWithCompletionHandler:(void (^)(void))handler;
  63. /**
  64. * 通过这个方法写入数据
  65. *
  66. * @param sampleBuffer 写入的数据
  67. * @param isVideo 是否写入的是视频
  68. *
  69. * @return 写入是否成功
  70. */
  71. - (BOOL)encodeFrame:(CMSampleBufferRef)sampleBuffer pixelBuffer:(CVPixelBufferRef)buffer isVideo:(BOOL)isVideo;
  72. - (void)initAudioInputChannels:(int)ch samples:(Float64)rate;
  73. @end