forked from BradLarson/GPUImage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request BradLarson#1886 from RedQueenCoder/SimpleVideoFilt…
…erPullRequest Sample project showing how to save filtered video on the Mac
- Loading branch information
Showing
12 changed files
with
1,485 additions
and
0 deletions.
There are no files selected for viewing
497 changes: 497 additions & 0 deletions
497
examples/Mac/SimpleVideoFilter/SimpleVideoFilter.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
examples/Mac/SimpleVideoFilter/SimpleVideoFilter/AppDelegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#import <Cocoa/Cocoa.h> | ||
#import "SLSSimpleVideoFilterWindowController.h" | ||
|
||
@interface AppDelegate : NSObject <NSApplicationDelegate> | ||
{ | ||
SLSSimpleVideoFilterWindowController *simpleVideoFilterWindowController; | ||
} | ||
|
||
@end | ||
|
21 changes: 21 additions & 0 deletions
21
examples/Mac/SimpleVideoFilter/SimpleVideoFilter/AppDelegate.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#import "AppDelegate.h" | ||
#import <GPUImage/GPUImage.h> | ||
|
||
@interface AppDelegate () | ||
|
||
@property (weak) IBOutlet NSWindow *window; | ||
@end | ||
|
||
@implementation AppDelegate | ||
|
||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | ||
// Insert code here to initialize your application | ||
simpleVideoFilterWindowController = [[SLSSimpleVideoFilterWindowController alloc] initWithWindowNibName:@"SLSSimpleVideoFilterWindowController"]; | ||
[simpleVideoFilterWindowController showWindow:self]; | ||
} | ||
|
||
- (void)applicationWillTerminate:(NSNotification *)aNotification { | ||
// Insert code here to tear down your application | ||
} | ||
|
||
@end |
676 changes: 676 additions & 0 deletions
676
examples/Mac/SimpleVideoFilter/SimpleVideoFilter/Base.lproj/MainMenu.xib
Large diffs are not rendered by default.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
.../Mac/SimpleVideoFilter/SimpleVideoFilter/Images.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
examples/Mac/SimpleVideoFilter/SimpleVideoFilter/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.redqueencoder.$(PRODUCT_NAME:rfc1034identifier)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2015 Red Queen Coder, LLC. All rights reserved.</string> | ||
<key>NSMainNibFile</key> | ||
<string>MainMenu</string> | ||
<key>NSPrincipalClass</key> | ||
<string>NSApplication</string> | ||
</dict> | ||
</plist> |
13 changes: 13 additions & 0 deletions
13
examples/Mac/SimpleVideoFilter/SimpleVideoFilter/SLSSimpleVideoFilterWindowController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#import <Cocoa/Cocoa.h> | ||
#import <GPUImage/GPUImage.h> | ||
|
||
@interface SLSSimpleVideoFilterWindowController : NSWindowController | ||
{ | ||
GPUImageAVCamera *videoCamera; | ||
GPUImageOutput<GPUImageInput> *filter; | ||
GPUImageMovieWriter *movieWriter; | ||
} | ||
|
||
@property (weak) IBOutlet GPUImageView *videoView; | ||
|
||
@end |
65 changes: 65 additions & 0 deletions
65
examples/Mac/SimpleVideoFilter/SimpleVideoFilter/SLSSimpleVideoFilterWindowController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#import "SLSSimpleVideoFilterWindowController.h" | ||
|
||
@interface SLSSimpleVideoFilterWindowController () | ||
|
||
@end | ||
|
||
@implementation SLSSimpleVideoFilterWindowController | ||
|
||
|
||
- (void)windowDidLoad { | ||
[super windowDidLoad]; | ||
|
||
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. | ||
|
||
// Instantiate video camera | ||
videoCamera = [[GPUImageAVCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraDevice:nil]; | ||
videoCamera.runBenchmark = YES; | ||
|
||
// Create filter and add it to target | ||
filter = [[GPUImageSepiaFilter alloc] init]; | ||
[videoCamera addTarget:filter]; | ||
|
||
// Save video to desktop | ||
NSError *error = nil; | ||
|
||
NSURL *pathToDesktop = [[NSFileManager defaultManager] URLForDirectory:NSDesktopDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&error]; | ||
NSURL *pathToMovieFile = [pathToDesktop URLByAppendingPathComponent:@"movie.mp4"]; | ||
NSString *filePathString = [pathToMovieFile absoluteString]; | ||
NSString *filePathSubstring = [filePathString substringFromIndex:7]; | ||
unlink([filePathSubstring UTF8String]); | ||
|
||
// Instantiate movie writer and add targets | ||
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:pathToMovieFile size:CGSizeMake(640.0, 480.0)]; | ||
movieWriter.encodingLiveVideo = YES; | ||
|
||
self.videoView.fillMode = kGPUImageFillModePreserveAspectRatio; | ||
[filter addTarget:movieWriter]; | ||
[filter addTarget:self.videoView]; | ||
|
||
// Start capturing | ||
[videoCamera startCameraCapture]; | ||
|
||
double delayToStartRecording = 0.5; | ||
dispatch_time_t startTime = dispatch_time(DISPATCH_TIME_NOW, delayToStartRecording * NSEC_PER_SEC); | ||
dispatch_after(startTime, dispatch_get_main_queue(), ^(void){ | ||
NSLog(@"Start recording"); | ||
|
||
videoCamera.audioEncodingTarget = movieWriter; | ||
[movieWriter startRecording]; | ||
|
||
double delayInSeconds = 10.0; | ||
dispatch_time_t stopTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); | ||
dispatch_after(stopTime, dispatch_get_main_queue(), ^(void){ | ||
|
||
[filter removeTarget:movieWriter]; | ||
videoCamera.audioEncodingTarget = nil; | ||
[movieWriter finishRecording]; | ||
NSLog(@"Movie completed"); | ||
|
||
}); | ||
}); | ||
|
||
} | ||
|
||
@end |
34 changes: 34 additions & 0 deletions
34
examples/Mac/SimpleVideoFilter/SimpleVideoFilter/SLSSimpleVideoFilterWindowController.xib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/> | ||
</dependencies> | ||
<objects> | ||
<customObject id="-2" userLabel="File's Owner" customClass="SLSSimpleVideoFilterWindowController"> | ||
<connections> | ||
<outlet property="videoView" destination="dd0-IN-e64" id="tXV-v8-36j"/> | ||
<outlet property="window" destination="QvC-M9-y7g" id="eyV-Nd-iwu"/> | ||
</connections> | ||
</customObject> | ||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> | ||
<customObject id="-3" userLabel="Application" customClass="NSObject"/> | ||
<window title="Simple Video Filter View" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g"> | ||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> | ||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> | ||
<rect key="contentRect" x="196" y="240" width="660" height="500"/> | ||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/> | ||
<view key="contentView" id="EiT-Mj-1SZ"> | ||
<rect key="frame" x="0.0" y="0.0" width="660" height="500"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
<subviews> | ||
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dd0-IN-e64" customClass="GPUImageView"> | ||
<rect key="frame" x="10" y="10" width="640" height="480"/> | ||
</customView> | ||
</subviews> | ||
</view> | ||
<connections> | ||
<outlet property="delegate" destination="-2" id="viU-Oc-5RF"/> | ||
</connections> | ||
</window> | ||
</objects> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// main.m | ||
// SimpleVideoFilter | ||
// | ||
// Created by Janie Clayton-Hasz on 1/8/15. | ||
// Copyright (c) 2015 Red Queen Coder, LLC. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
int main(int argc, const char * argv[]) { | ||
return NSApplicationMain(argc, argv); | ||
} |
24 changes: 24 additions & 0 deletions
24
examples/Mac/SimpleVideoFilter/SimpleVideoFilterTests/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.redqueencoder.$(PRODUCT_NAME:rfc1034identifier)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
40 changes: 40 additions & 0 deletions
40
examples/Mac/SimpleVideoFilter/SimpleVideoFilterTests/SimpleVideoFilterTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// SimpleVideoFilterTests.m | ||
// SimpleVideoFilterTests | ||
// | ||
// Created by Janie Clayton-Hasz on 1/8/15. | ||
// Copyright (c) 2015 Red Queen Coder, LLC. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <XCTest/XCTest.h> | ||
|
||
@interface SimpleVideoFilterTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation SimpleVideoFilterTests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
- (void)tearDown { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testExample { | ||
// This is an example of a functional test case. | ||
XCTAssert(YES, @"Pass"); | ||
} | ||
|
||
- (void)testPerformanceExample { | ||
// This is an example of a performance test case. | ||
[self measureBlock:^{ | ||
// Put the code you want to measure the time of here. | ||
}]; | ||
} | ||
|
||
@end |