Skip to content

Commit 42bd5c1

Browse files
author
chenliming
committed
update waterMark postion and set outVideoSize
1 parent 41393ff commit 42bd5c1

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

LFLiveKit/LFLiveSession.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
@property (nonatomic, assign) NSUInteger reconnectCount;
8686

8787
/*** The warterMarkView control whether the watermark is displayed or not ,if set ni,will remove watermark,otherwise add.
88-
set alpha represent mix.Position relative to preview.
88+
set alpha represent mix.Position relative to outVideoSize.
8989
*.*/
9090
@property (nonatomic, strong) UIView *warterMarkView;
9191

LFLiveKit/capture/LFVideoCapture.m

+7-3
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ - (void)setRunning:(BOOL)running {
102102
- (void)setPreView:(UIView *)preView {
103103
if (self.gpuImageView.superview) [self.gpuImageView removeFromSuperview];
104104
[preView insertSubview:self.gpuImageView atIndex:0];
105-
self.gpuImageView.bounds = preView.bounds;
106-
self.waterMarkContentView.bounds = preView.bounds;
105+
self.gpuImageView.frame = CGRectMake(0, 0, preView.frame.size.width, preView.frame.size.height);
107106
}
108107

109108
- (UIView *)preView {
@@ -257,7 +256,12 @@ - (void)processVideo:(GPUImageOutput *)output {
257256
GPUImageFramebuffer *imageFramebuffer = output.framebufferForOutput;
258257
CVPixelBufferRef pixelBuffer = [imageFramebuffer pixelBuffer];
259258
if(!CGSizeEqualToSize(_self.configuration.videoSize, imageFramebuffer.size)){
260-
_self.configuration.videoSize = imageFramebuffer.size;
259+
NSInteger width = ceil(imageFramebuffer.size.width);
260+
NSInteger height = ceil(imageFramebuffer.size.height);
261+
if(width %2 != 0) width = width + 1;
262+
if(height %2 != 0) height = height + 1;
263+
_self.configuration.videoSize = CGSizeMake(width, height);
264+
_self.waterMarkContentView.frame = CGRectMake(0, 0,_self.configuration.videoSize.width, _self.configuration.videoSize.height);
261265
}
262266
if (pixelBuffer && _self.delegate && [_self.delegate respondsToSelector:@selector(captureOutput:pixelBuffer:)]) {
263267
[_self.delegate captureOutput:_self pixelBuffer:pixelBuffer];

LFLiveKit/configuration/LFLiveVideoConfiguration.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ typedef NS_ENUM (NSUInteger, LFLiveVideoQuality){
5757
///=============================================================================
5858
/// @name Attribute
5959
///=============================================================================
60-
/// 视频的分辨率,宽高务必设定为 2 的倍数,否则解码播放时可能出现绿边
60+
/// 视频的分辨率,宽高务必设定为 2 的倍数,否则解码播放时可能出现绿边(这个videoSizeRespectingAspectRatio设置为YES则可能会改变)
6161
@property (nonatomic, assign) CGSize videoSize;
6262

6363
/// 输出图像是否等比例,默认为YES

LFLiveKitDemo/LFLiveKitDemo/LFLivePreview.m

+7-7
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,17 @@ - (LFLiveSession *)session {
207207
audioConfiguration.audioSampleRate = LFLiveAudioSampleRate_44100Hz;
208208
209209
LFLiveVideoConfiguration *videoConfiguration = [LFLiveVideoConfiguration new];
210-
videoConfiguration.videoSize = CGSizeMake(500, 700);
210+
videoConfiguration.videoSize = CGSizeMake(720, 1280);
211211
videoConfiguration.videoBitRate = 800*1024;
212212
videoConfiguration.videoMaxBitRate = 1000*1024;
213213
videoConfiguration.videoMinBitRate = 500*1024;
214214
videoConfiguration.videoFrameRate = 15;
215215
videoConfiguration.videoMaxKeyframeInterval = 30;
216216
videoConfiguration.landscape = NO;
217-
videoConfiguration.sessionPreset = LFCaptureSessionPreset720x1280;
217+
videoConfiguration.sessionPreset = LFCaptureSessionPreset360x640;
218218
219219
_session = [[LFLiveSession alloc] initWithAudioConfiguration:audioConfiguration videoConfiguration:videoConfiguration];
220-
*/
220+
*/
221221

222222

223223
/**   自己定制高质量音频128K 分辨率设置为720*1280 方向横屏 */
@@ -229,14 +229,14 @@ - (LFLiveSession *)session {
229229
audioConfiguration.audioSampleRate = LFLiveAudioSampleRate_44100Hz;
230230
231231
LFLiveVideoConfiguration *videoConfiguration = [LFLiveVideoConfiguration new];
232-
videoConfiguration.videoSize = CGSizeMake(720, 1280);
232+
videoConfiguration.videoSize = CGSizeMake(1280, 720);
233233
videoConfiguration.videoBitRate = 800*1024;
234234
videoConfiguration.videoMaxBitRate = 1000*1024;
235235
videoConfiguration.videoMinBitRate = 500*1024;
236236
videoConfiguration.videoFrameRate = 15;
237237
videoConfiguration.videoMaxKeyframeInterval = 30;
238-
videoConfiguration.landscape = NO;
239-
videoConfiguration.sessionPreset = LFCaptureSessionPreset360x640;
238+
videoConfiguration.landscape = YES;
239+
videoConfiguration.sessionPreset = LFCaptureSessionPreset720x1280;
240240
241241
_session = [[LFLiveSession alloc] initWithAudioConfiguration:audioConfiguration videoConfiguration:videoConfiguration];
242242
*/
@@ -247,7 +247,7 @@ - (LFLiveSession *)session {
247247

248248
UIImageView *imageView = [[UIImageView alloc] init];
249249
imageView.alpha = 0.8;
250-
imageView.frame = CGRectMake(320-29, 100, 29, 29);
250+
imageView.frame = CGRectMake(100, 100, 29, 29);
251251
imageView.image = [UIImage imageNamed:@"ios-29x29"];
252252
_session.warterMarkView = imageView;
253253

0 commit comments

Comments
 (0)