From 02fa78b9e34591071933f7f498de774d511260b5 Mon Sep 17 00:00:00 2001 From: zher52 Date: Mon, 11 Oct 2021 19:49:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8F=82=E6=95=B0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ios/SGRecord/SGRecordEncoder.m | 10 +++++----- src/ios/SGRecord/SGRecordManager.m | 2 +- src/ios/SGRecord/SGRecordOptions.h | 12 ++++++------ src/ios/SGRecord/SGRecordOptions.m | 6 ++++-- src/ios/SGRecord/SGRecordViewController.m | 4 ++-- www/capture.js | 8 ++++---- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/ios/SGRecord/SGRecordEncoder.m b/src/ios/SGRecord/SGRecordEncoder.m index 0686fe8..d2c9ded 100644 --- a/src/ios/SGRecord/SGRecordEncoder.m +++ b/src/ios/SGRecord/SGRecordEncoder.m @@ -51,14 +51,14 @@ //初始化视频输入 - (void)initVideoInputHeight { // 码率和帧率设置 - NSDictionary *compressionProperties = @{ AVVideoAverageBitRateKey:@(self.options.bitRate), - AVVideoExpectedSourceFrameRateKey:@(self.options.frameRate), - AVVideoMaxKeyFrameIntervalKey:@(self.options.frameRate), + NSDictionary *compressionProperties = @{ AVVideoAverageBitRateKey:@(self.options.bitRate.intValue), + AVVideoExpectedSourceFrameRateKey:@(self.options.frameRate.intValue), + AVVideoMaxKeyFrameIntervalKey:@(self.options.frameRate.intValue), AVVideoProfileLevelKey:AVVideoProfileLevelH264BaselineAutoLevel }; NSDictionary* settings = @{AVVideoCodecKey:AVVideoCodecH264, AVVideoScalingModeKey:AVVideoScalingModeResizeAspectFill, - AVVideoWidthKey:@(self.options.width), - AVVideoHeightKey:@(self.options.height), + AVVideoWidthKey:@(self.options.width.intValue), + AVVideoHeightKey:@(self.options.height.intValue), AVVideoCompressionPropertiesKey:compressionProperties }; //初始化视频写入类 diff --git a/src/ios/SGRecord/SGRecordManager.m b/src/ios/SGRecord/SGRecordManager.m index 08a9eda..5ab0a70 100644 --- a/src/ios/SGRecord/SGRecordManager.m +++ b/src/ios/SGRecord/SGRecordManager.m @@ -47,7 +47,7 @@ typedef void(^PropertyChangeBlock)(AVCaptureDevice *captureDevice); - (instancetype)init { self = [super init]; if (self) { - self.maxRecordTime = self.options.duration; + self.maxRecordTime = self.options.duration.intValue; } return self; } diff --git a/src/ios/SGRecord/SGRecordOptions.h b/src/ios/SGRecord/SGRecordOptions.h index a4932d1..61a2bec 100644 --- a/src/ios/SGRecord/SGRecordOptions.h +++ b/src/ios/SGRecord/SGRecordOptions.h @@ -12,12 +12,12 @@ @property (nonatomic, weak) id commandDelegate; @property (strong) NSString* callbackId; - @property (assign) NSInteger frameRate; - @property (assign) NSInteger bitRate; - @property (assign) NSInteger width; - @property (assign) NSInteger height; - @property (assign) NSInteger limit;// 录制视频最短时间 - @property (assign) NSInteger duration; + @property (strong) NSNumber * frameRate; + @property (strong) NSNumber * bitRate; + @property (strong) NSNumber * width; + @property (strong) NSNumber * height; + @property (strong) NSNumber * limit;// 录制视频最短时间 + @property (strong) NSNumber * duration; + (instancetype) createFromArguments:(CDVInvokedUrlCommand*)command; @end diff --git a/src/ios/SGRecord/SGRecordOptions.m b/src/ios/SGRecord/SGRecordOptions.m index 16c7c97..ae5747b 100644 --- a/src/ios/SGRecord/SGRecordOptions.m +++ b/src/ios/SGRecord/SGRecordOptions.m @@ -16,10 +16,12 @@ options.width = [command argumentAtIndex:0 withDefault:@(360)]; options.height = [command argumentAtIndex:1 withDefault:@(640)]; 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.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; } @end diff --git a/src/ios/SGRecord/SGRecordViewController.m b/src/ios/SGRecord/SGRecordViewController.m index e1e5c77..16175f8 100644 --- a/src/ios/SGRecord/SGRecordViewController.m +++ b/src/ios/SGRecord/SGRecordViewController.m @@ -363,7 +363,7 @@ NSLog(@"开始录制视频"); [self.recordButton setScale]; [self startRecord]; - } else if (_timeInterval >= RECORD_TIME + self.options.limit) { + } else if (_timeInterval >= RECORD_TIME + self.options.limit.intValue) { [self removeTimer]; } } @@ -378,7 +378,7 @@ - (void)toucheUpInsideOrOutSide:(UIButton *)button{ NSLog(@"抬起按钮:__timeInterval==:%f",_timeInterval); [self removeTimer]; - if (_timeInterval >= RECORD_TIME && _timeInterval < RECORD_TIME + self.options.limit) { + if (_timeInterval >= RECORD_TIME && _timeInterval < RECORD_TIME + self.options.limit.intValue) { // 录制时间太短 NSLog(@"录制时间太短"); [self stopRecord:NO]; diff --git a/www/capture.js b/www/capture.js index 3a48297..c5687dd 100644 --- a/www/capture.js +++ b/www/capture.js @@ -5,10 +5,10 @@ module.exports = { capture(option, success, error) { var getValue = argscheck.getValue; - var width = getValue(option.width, 360); - var height = getValue(option.height, 640); - var frameRate = getValue(option.frameRate, 30); - var bitRate = getValue(option.bitRate, width * height * 6); + var width = getValue(option.width, null); + var height = getValue(option.height, null); + var frameRate = getValue(option.frameRate, null); + var bitRate = getValue(option.bitRate, null); var limit = getValue(option.limit, 3); var duration = getValue(option.duration, 10); exec(success, error, 'CapturePlugin', 'capture', [width,height,frameRate,bitRate,limit,duration]);