处理参数异常

This commit is contained in:
zher52 2021-10-11 19:49:36 +08:00
parent ec0ea741a7
commit 02fa78b9e3
6 changed files with 22 additions and 20 deletions

View File

@ -51,14 +51,14 @@
// //
- (void)initVideoInputHeight { - (void)initVideoInputHeight {
// //
NSDictionary *compressionProperties = @{ AVVideoAverageBitRateKey:@(self.options.bitRate), NSDictionary *compressionProperties = @{ AVVideoAverageBitRateKey:@(self.options.bitRate.intValue),
AVVideoExpectedSourceFrameRateKey:@(self.options.frameRate), AVVideoExpectedSourceFrameRateKey:@(self.options.frameRate.intValue),
AVVideoMaxKeyFrameIntervalKey:@(self.options.frameRate), AVVideoMaxKeyFrameIntervalKey:@(self.options.frameRate.intValue),
AVVideoProfileLevelKey:AVVideoProfileLevelH264BaselineAutoLevel }; AVVideoProfileLevelKey:AVVideoProfileLevelH264BaselineAutoLevel };
NSDictionary* settings = @{AVVideoCodecKey:AVVideoCodecH264, NSDictionary* settings = @{AVVideoCodecKey:AVVideoCodecH264,
AVVideoScalingModeKey:AVVideoScalingModeResizeAspectFill, AVVideoScalingModeKey:AVVideoScalingModeResizeAspectFill,
AVVideoWidthKey:@(self.options.width), AVVideoWidthKey:@(self.options.width.intValue),
AVVideoHeightKey:@(self.options.height), AVVideoHeightKey:@(self.options.height.intValue),
AVVideoCompressionPropertiesKey:compressionProperties }; AVVideoCompressionPropertiesKey:compressionProperties };
// //

View File

@ -47,7 +47,7 @@ typedef void(^PropertyChangeBlock)(AVCaptureDevice *captureDevice);
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if (self) { if (self) {
self.maxRecordTime = self.options.duration; self.maxRecordTime = self.options.duration.intValue;
} }
return self; return self;
} }

View File

@ -12,12 +12,12 @@
@property (nonatomic, weak) id <CDVCommandDelegate> commandDelegate; @property (nonatomic, weak) id <CDVCommandDelegate> commandDelegate;
@property (strong) NSString* callbackId; @property (strong) NSString* callbackId;
@property (assign) NSInteger frameRate; @property (strong) NSNumber * frameRate;
@property (assign) NSInteger bitRate; @property (strong) NSNumber * bitRate;
@property (assign) NSInteger width; @property (strong) NSNumber * width;
@property (assign) NSInteger height; @property (strong) NSNumber * height;
@property (assign) NSInteger limit;// 录制视频最短时间 @property (strong) NSNumber * limit;// 录制视频最短时间
@property (assign) NSInteger duration; @property (strong) NSNumber * duration;
+ (instancetype) createFromArguments:(CDVInvokedUrlCommand*)command; + (instancetype) createFromArguments:(CDVInvokedUrlCommand*)command;
@end @end

View File

@ -16,10 +16,12 @@
options.width = [command argumentAtIndex:0 withDefault:@(360)]; options.width = [command argumentAtIndex:0 withDefault:@(360)];
options.height = [command argumentAtIndex:1 withDefault:@(640)]; options.height = [command argumentAtIndex:1 withDefault:@(640)];
options.frameRate = [command argumentAtIndex:2 withDefault:@(30)]; options.frameRate = [command argumentAtIndex:2 withDefault:@(30)];
options.bitRate = [command argumentAtIndex:3 withDefault: @(options.height * options.width * 6)]; options.bitRate = [command argumentAtIndex:3 withDefault: @(options.height.intValue * options.width.intValue * 6)];
options.limit = [command argumentAtIndex:4 withDefault:@(3)]; options.limit = [command argumentAtIndex:4 withDefault:@(3)];
options.duration = [command argumentAtIndex:5 withDefault:@(10)]; options.duration = [command argumentAtIndex:5 withDefault:@(10)];
NSLog(@"width:%d - height:%d - frameRate:%d - bitRate:%d limit:%d dutation:%d",options.width,options.height,options.frameRate,options.bitRate,options.limit,options.duration); NSLog(@"width:%d - height:%d - frameRate:%d - bitRate:%d limit:%d dutation:%d",
options.width.intValue,options.height.intValue,options.frameRate.intValue,
options.bitRate.intValue,options.limit.intValue,options.duration.intValue);
return options; return options;
} }
@end @end

View File

@ -363,7 +363,7 @@
NSLog(@"开始录制视频"); NSLog(@"开始录制视频");
[self.recordButton setScale]; [self.recordButton setScale];
[self startRecord]; [self startRecord];
} else if (_timeInterval >= RECORD_TIME + self.options.limit) { } else if (_timeInterval >= RECORD_TIME + self.options.limit.intValue) {
[self removeTimer]; [self removeTimer];
} }
} }
@ -378,7 +378,7 @@
- (void)toucheUpInsideOrOutSide:(UIButton *)button{ - (void)toucheUpInsideOrOutSide:(UIButton *)button{
NSLog(@"抬起按钮:__timeInterval==:%f",_timeInterval); NSLog(@"抬起按钮:__timeInterval==:%f",_timeInterval);
[self removeTimer]; [self removeTimer];
if (_timeInterval >= RECORD_TIME && _timeInterval < RECORD_TIME + self.options.limit) { if (_timeInterval >= RECORD_TIME && _timeInterval < RECORD_TIME + self.options.limit.intValue) {
// //
NSLog(@"录制时间太短"); NSLog(@"录制时间太短");
[self stopRecord:NO]; [self stopRecord:NO];

View File

@ -5,10 +5,10 @@ module.exports = {
capture(option, success, error) { capture(option, success, error) {
var getValue = argscheck.getValue; var getValue = argscheck.getValue;
var width = getValue(option.width, 360); var width = getValue(option.width, null);
var height = getValue(option.height, 640); var height = getValue(option.height, null);
var frameRate = getValue(option.frameRate, 30); var frameRate = getValue(option.frameRate, null);
var bitRate = getValue(option.bitRate, width * height * 6); var bitRate = getValue(option.bitRate, null);
var limit = getValue(option.limit, 3); var limit = getValue(option.limit, 3);
var duration = getValue(option.duration, 10); var duration = getValue(option.duration, 10);
exec(success, error, 'CapturePlugin', 'capture', [width,height,frameRate,bitRate,limit,duration]); exec(success, error, 'CapturePlugin', 'capture', [width,height,frameRate,bitRate,limit,duration]);