Skip to content

Commit

Permalink
Better support of filters that modify the image frame in SCAssetExpor…
Browse files Browse the repository at this point in the history
…tSession.
  • Loading branch information
rFlex committed May 30, 2015
1 parent afde95a commit cc166d7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
12 changes: 8 additions & 4 deletions Library/Sources/SCAssetExportSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ - (BOOL)processSampleBuffer:(CMSampleBufferRef)sampleBuffer {
if (ret == kCVReturnSuccess) {
CVPixelBufferLockBaseAddress(outputPixelBuffer, 0);

[_ciContext render:result toCVPixelBuffer:outputPixelBuffer];
[_ciContext render:result toCVPixelBuffer:outputPixelBuffer bounds:result.extent colorSpace:CGColorSpaceCreateDeviceRGB()];

BOOL success = [self processPixelBuffer:outputPixelBuffer presentationTime:CMSampleBufferGetPresentationTimeStamp(sampleBuffer)];

Expand Down Expand Up @@ -257,6 +257,10 @@ - (BOOL)needsCIContext {

- (void)setupPixelBufferAdaptor:(CGSize)videoSize {
if ([self needsInputPixelBufferAdaptor] && _videoInput != nil) {
if (!CGSizeEqualToSize(self.videoConfiguration.bufferSize, CGSizeZero)) {
videoSize = self.videoConfiguration.bufferSize;
}

NSDictionary *pixelBufferAttributes = @{
(id)kCVPixelBufferPixelFormatTypeKey : [NSNumber numberWithInt:_pixelFormat],
(id)kCVPixelBufferWidthKey : [NSNumber numberWithFloat:videoSize.width],
Expand Down Expand Up @@ -374,9 +378,9 @@ - (void)exportAsynchronouslyWithCompletionHandler:(void (^)())completionHandler
// Output
_pixelFormat = [self needsCIContext] ? kVideoPixelFormatTypeForCI : kVideoPixelFormatTypeDefault;
NSDictionary *settings = @{
(id)kCVPixelBufferPixelFormatTypeKey : [NSNumber numberWithUnsignedInt:_pixelFormat],
(id)kCVPixelBufferIOSurfacePropertiesKey : [NSDictionary dictionary]
};
(id)kCVPixelBufferPixelFormatTypeKey : [NSNumber numberWithUnsignedInt:_pixelFormat],
(id)kCVPixelBufferIOSurfacePropertiesKey : [NSDictionary dictionary]
};

AVVideoComposition *videoComposition = self.videoConfiguration.composition;

Expand Down
4 changes: 2 additions & 2 deletions Library/Sources/SCImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ - (void)drawRect:(CGRect)rect {
if (image != nil) {
image = [image imageByApplyingTransform:self.preferredCIImageTransform];

CGRect extent = [image extent];

if (_filter != nil) {
image = [_filter imageByProcessingImage:image atTime:_CIImageTime];
}

CGRect extent = [image extent];

CGRect outputRect = [CIImageRendererUtils processRect:rect withImageSize:extent.size contentScale:self.contentScaleFactor contentMode:self.contentMode];

[_CIContext drawImage:image inRect:outputRect fromRect:extent];
Expand Down
9 changes: 9 additions & 0 deletions Library/Sources/SCVideoConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ typedef enum : NSUInteger {
*/
@property (assign, nonatomic) CGRect watermarkFrame;

/**
Specify a buffer size to use. If you are using a filter that modifies
the image size, you should the output size here.
Only used in SCAssetExportSession.
Default is CGSizeZero
*/
@property (assign, nonatomic) CGSize bufferSize;

/**
Set a specific key to the video profile
*/
Expand Down
4 changes: 2 additions & 2 deletions SCRecorder.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SCRecorder"
s.version = "2.4.5"
s.version = "2.4.7"
s.summary = "The camera engine that is complete, for real."

s.description = <<-DESC
Expand All @@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.license = 'Apache License, Version 2.0'
s.author = { "Simon CORSIN" => "simon@corsin.me" }
s.platform = :ios, '6.0'
s.source = { :git => "https://github.com/rFlex/SCRecorder.git", :tag => "v2.4.5" }
s.source = { :git => "https://github.com/rFlex/SCRecorder.git", :tag => "v2.4.7" }
s.source_files = 'Library/Sources/*.{h,m}'
s.public_header_files = 'Library/Sources/*.h'
s.requires_arc = true
Expand Down

0 comments on commit cc166d7

Please sign in to comment.