forked from rFlex/SCRecorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCVideoConfiguration.h
185 lines (147 loc) · 5.53 KB
/
SCVideoConfiguration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//
// SCVideoConfiguration.h
// SCRecorder
//
// Created by Simon CORSIN on 21/11/14.
// Copyright (c) 2014 rFlex. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "SCMediaTypeConfiguration.h"
#import "SCFilter.h"
#define kSCVideoConfigurationDefaultCodec AVVideoCodecH264
#define kSCVideoConfigurationDefaultScalingMode AVVideoScalingModeResizeAspectFill
#define kSCVideoConfigurationDefaultBitrate 2000000
typedef enum : NSUInteger {
SCWatermarkAnchorLocationTopLeft,
SCWatermarkAnchorLocationTopRight,
SCWatermarkAnchorLocationBottomLeft,
SCWatermarkAnchorLocationBottomRight
} SCWatermarkAnchorLocation;
@protocol SCVideoOverlay <NSObject>
@optional
/**
Called to determine whether setFrame:, updateWithVideoTime: and layoutIfNeeded should be called on the main thread.
You should avoid returning YES as much as possible from this method, since it will potentially
greatly reduce the encoding speed. Some views like UITextView requires to layout on the main thread.
*/
- (BOOL)requiresUpdateOnMainThreadAtVideoTime:(NSTimeInterval)time videoSize:(CGSize)videoSize;
/**
Update the underlying view with the given time.
This method will be called on the main thread if requiresVideoTimeUpdateOnMainThread returns true,
otherwise it will be called in an arbitrary queue managed by the SCAssetExportSession.
*/
- (void)updateWithVideoTime:(NSTimeInterval)time;
@end
@interface SCVideoConfiguration : SCMediaTypeConfiguration
/**
Change the size of the video
If options has been changed, this property will be ignored
If this value is CGSizeZero, the input video size received
from the camera will be used
Default is CGSizeZero
*/
@property (assign, nonatomic) CGSize size;
/**
Change the affine transform for the video
If options has been changed, this property will be ignored
*/
@property (assign, nonatomic) CGAffineTransform affineTransform;
/**
Set the codec used for the video
Default is AVVideoCodecH264
*/
@property (copy, nonatomic) NSString *__nonnull codec;
/**
Set the video scaling mode
*/
@property (copy, nonatomic) NSString *__nonnull scalingMode;
/**
The maximum framerate that this SCRecordSession should handle
If the camera appends too much frames, they will be dropped.
If this property's value is 0, it will use the current video
framerate from the camera.
*/
@property (assign, nonatomic) CMTimeScale maxFrameRate;
/**
The time scale of the video
A value more than 1 will make the buffers last longer, it creates
a slow motion effect. A value less than 1 will make the buffers be
shorter, it creates a timelapse effect.
Only used in SCRecorder.
*/
@property (assign, nonatomic) CGFloat timeScale;
/**
If true and videoSize is CGSizeZero, the videoSize
used will equal to the minimum width or height found,
thus making the video square.
*/
@property (assign, nonatomic) BOOL sizeAsSquare;
/**
If true, each frame will be encoded as a keyframe
This is needed if you want to merge the recordSegments using
the passthrough preset. This will seriously impact the video
size. You can set this to NO and change the recordSegmentsMergePreset if you want
a better quality/size ratio, but the merge will be slower.
Default is NO
*/
@property (assign, nonatomic) BOOL shouldKeepOnlyKeyFrames;
/**
If not nil, each appended frame will be processed by this SCFilter.
While it seems convenient, this removes the possibility to change the
filter after the segment has been added.
Setting a new filter will cause the SCRecordSession to stop the
current record segment if the previous filter was NIL and the
new filter is NOT NIL or vice versa. If you want to have a smooth
transition between filters in the same record segment, make sure to set
an empty SCFilterGroup instead of setting this property to nil.
*/
@property (strong, nonatomic) SCFilter *__nullable filter;
/**
If YES, the affineTransform will be ignored and the output affineTransform
will be the same as the input asset.
Only used in SCAssetExportSession.
*/
@property (assign, nonatomic) BOOL keepInputAffineTransform;
/**
The video composition to use.
Only used in SCAssetExportSession.
*/
@property (strong, nonatomic) AVVideoComposition *__nullable composition;
/**
The watermark to use. If the composition is not set, this watermark
image will be applied on the exported video.
Only used in SCAssetExportSession.
*/
@property (strong, nonatomic) UIImage *__nullable watermarkImage;
/**
The watermark image location and size in the input video frame coordinates.
Only used in SCAssetExportSession.
*/
@property (assign, nonatomic) CGRect watermarkFrame;
/**
Specify a buffer size to use. By default the SCAssetExportSession tries
to figure out which size to use by looking at the composition and the natural
size of the inputAsset. If the filter you set return back an image with a different
size, you should put the output size here.
Only used in SCAssetExportSession.
Default is CGSizeZero
*/
@property (assign, nonatomic) CGSize bufferSize;
/**
Set a specific key to the video profile
*/
@property (assign, nonatomic) NSString *__nullable profileLevel;
/**
The overlay view that will be drawn on top of the video.
Only used in SCAssetExportSession.
*/
@property (strong, nonatomic) UIView<SCVideoOverlay> *__nullable overlay;
/**
The watermark anchor location.
Default is top left
Only used in SCAssetExportSession.
*/
@property (assign, nonatomic) SCWatermarkAnchorLocation watermarkAnchorLocation;
- (NSDictionary *__nonnull)createAssetWriterOptionsWithVideoSize:(CGSize)videoSize;
@end