Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: noppefoxwolf/SCNVideoWriter
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.4.0
Choose a base ref
...
head repository: noppefoxwolf/SCNVideoWriter
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 6 commits
  • 12 files changed
  • 4 contributors

Commits on Aug 20, 2017

  1. Fix crop issue

    noppefoxwolf committed Aug 20, 2017
    Copy the full SHA
    4b3adec View commit details
  2. version up

    noppefoxwolf committed Aug 20, 2017
    Copy the full SHA
    f132dc1 View commit details
  3. project settings

    noppefoxwolf committed Aug 20, 2017
    Copy the full SHA
    c3257ca View commit details

Commits on Sep 19, 2017

  1. Migrate to Swift4

    ryohey committed Sep 19, 2017
    Copy the full SHA
    988c85f View commit details

Commits on Sep 28, 2017

  1. Merge pull request #11 from ryohey/migrate-swift4

    Migrate to Swift4
    noppefoxwolf authored Sep 28, 2017
    Copy the full SHA
    492b001 View commit details

Commits on Oct 31, 2017

  1. fix readme

    🦊Tomoya Hirano committed Oct 31, 2017
    Copy the full SHA
    ae23d81 View commit details
1 change: 1 addition & 0 deletions Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
platform :ios, '10.0'
use_frameworks!

target 'SCNVideoWriter_Example' do
10 changes: 5 additions & 5 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- SCNVideoWriter (0.1.0)
- SCNVideoWriter (0.5.0)

DEPENDENCIES:
- SCNVideoWriter (from `../`)

EXTERNAL SOURCES:
SCNVideoWriter:
:path: "../"
:path: ../

SPEC CHECKSUMS:
SCNVideoWriter: 29d821b31cef64659f204f9cc574242b95d8d538
SCNVideoWriter: cc277dde2b4cc905d06f0a262f1f50b777e7a32d

PODFILE CHECKSUM: 82bad70245a28ecd3a0db4c94adf58fcf37db6d6
PODFILE CHECKSUM: eaf2afc00a8480151634f3ef4607aaf4100137eb

COCOAPODS: 1.3.0.beta.1
COCOAPODS: 1.3.1
39 changes: 31 additions & 8 deletions Example/SCNVideoWriter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -238,7 +238,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
@@ -250,7 +250,7 @@
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = FBQ6Z8AF3U;
LastSwiftMigration = 0820;
LastSwiftMigration = 0900;
ProvisioningStyle = Manual;
TestTargetID = 607FACCF1AFB9204008FA782;
};
@@ -319,13 +319,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-SCNVideoWriter_Tests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
A1B699F35D66F0339FC0E592 /* [CP] Copy Pods Resources */ = {
@@ -364,9 +367,12 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-SCNVideoWriter_Example/Pods-SCNVideoWriter_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/SCNVideoWriter/SCNVideoWriter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SCNVideoWriter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -379,13 +385,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-SCNVideoWriter_Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@@ -448,14 +457,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -495,14 +510,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -542,7 +563,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "905ee6bd-d0b8-4820-ab2d-03b079ef72eb";
PROVISIONING_PROFILE_SPECIFIER = "noppelabs-*";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -561,7 +582,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "905ee6bd-d0b8-4820-ab2d-03b079ef72eb";
PROVISIONING_PROFILE_SPECIFIER = "noppelabs-*";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -585,7 +606,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -605,7 +627,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -69,6 +70,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
4 changes: 2 additions & 2 deletions Example/SCNVideoWriter/ARViewController.swift
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ final class ARViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
sceneView.session.run(ARWorldTrackingSessionConfiguration())
sceneView.session.run(ARWorldTrackingConfiguration())
}

override func viewDidDisappear(_ animated: Bool) {
@@ -63,7 +63,7 @@ final class ARViewController: UIViewController {
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
}) { (done, error) in
print(done, error)
print(done, error as Any)
}
}
}
2 changes: 1 addition & 1 deletion Example/SCNVideoWriter/SCNViewController.swift
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ final class SCNViewController: UIViewController {
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
}) { (done, error) in
print(done, error)
print(done, error as Any)
}
}
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Recommendation

If you want to record ARKit, try ARKitRecorder.
Real Time record, Aspect ratio and timestamp are perfect.

https://github.com/noppefoxwolf/ARKitRecorder


# SCNVideoWriter

[![Version](https://img.shields.io/cocoapods/v/SCNVideoWriter.svg?style=flat)](http://cocoapods.org/pods/SCNVideoWriter)
2 changes: 1 addition & 1 deletion SCNVideoWriter.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SCNVideoWriter'
s.version = '0.4.0'
s.version = '0.5.0'
s.summary = 'A simple recorder for SceneKit.'

s.description = <<-DESC
13 changes: 13 additions & 0 deletions SCNVideoWriter/Classes/Error.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Error.swift
// Pods-SCNVideoWriter_Example
//
// Created by Tomoya Hirano on 2017/08/20.
//

import UIKit

extension SCNVideoWriter {
public struct VideoSizeError: Error {}
}

49 changes: 49 additions & 0 deletions SCNVideoWriter/Classes/Options.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Options.swift
// Pods-SCNVideoWriter_Example
//
// Created by Tomoya Hirano on 2017/08/20.
//

import UIKit
import AVFoundation

extension SCNVideoWriter {
public struct Options {
public var timeScale: Int32
public var renderSize: CGSize
public var videoSize: CGSize
public var fps: Int
public var outputUrl: URL
public var fileType: String
public var codec: String
public var deleteFileIfExists: Bool

public static var `default`: Options {
return Options(timeScale: 600,
renderSize: CGSize(width: 640, height: 640),
videoSize: CGSize(width: 1280, height: 720),
fps: 60,
outputUrl: URL(fileURLWithPath: NSTemporaryDirectory() + "output.mp4"),
fileType: AVFileType.m4v.rawValue,
codec: AVVideoCodecH264,
deleteFileIfExists: true)
}

var assetWriterInputSettings: [String : Any] {
return [
AVVideoCodecKey: codec,
AVVideoWidthKey: videoSize.width,
AVVideoHeightKey: videoSize.height
]
}
var sourcePixelBufferAttributes: [String : Any] {
return [
kCVPixelBufferPixelFormatTypeKey as String: NSNumber(value: kCVPixelFormatType_32ARGB),
kCVPixelBufferWidthKey as String: videoSize.width,
kCVPixelBufferHeightKey as String: videoSize.height,
]
}
}
}

46 changes: 4 additions & 42 deletions SCNVideoWriter/Classes/SCNVideoWriter.swift
Original file line number Diff line number Diff line change
@@ -40,10 +40,9 @@ public class SCNVideoWriter {
renderer.scene = scene

self.writer = try AVAssetWriter(outputURL: options.outputUrl,
fileType: options.fileType)
self.input = AVAssetWriterInput(mediaType: AVMediaTypeVideo,
fileType: AVFileType(rawValue: options.fileType))
self.input = AVAssetWriterInput(mediaType: AVMediaType.video,
outputSettings: options.assetWriterInputSettings)
//input.expectsMediaDataInRealTime = true
self.pixelBufferAdaptor = AVAssetWriterInputPixelBufferAdaptor(assetWriterInput: input,
sourcePixelBufferAttributes: options.sourcePixelBufferAttributes)
prepare(with: options)
@@ -102,7 +101,7 @@ public class SCNVideoWriter {
autoreleasepool {
currentTime = CFAbsoluteTimeGetCurrent() - initialTime
let image = renderer.snapshot(atTime: currentTime, with: renderSize, antialiasingMode: .multisampling4X)
let croppedImage = image.crop(at: videoSize)
guard let croppedImage = image.fill(at: videoSize) else { return }
guard let pixelBuffer = PixelBufferFactory.make(with: videoSize, from: croppedImage, usingBuffer: pool) else { return }
let value: Int64 = Int64(currentTime * CFTimeInterval(options.timeScale))
let presentationTime = CMTimeMake(value, options.timeScale)
@@ -117,41 +116,4 @@ public class SCNVideoWriter {
}
}

extension SCNVideoWriter {
public struct Options {
public var timeScale: Int32
public var renderSize: CGSize
public var videoSize: CGSize
public var fps: Int
public var outputUrl: URL
public var fileType: String
public var codec: String
public var deleteFileIfExists: Bool

public static var `default`: Options {
return Options(timeScale: 600,
renderSize: CGSize(width: 640, height: 640),
videoSize: CGSize(width: 640, height: 640),
fps: 60,
outputUrl: URL(fileURLWithPath: NSTemporaryDirectory() + "output.mp4"),
fileType: AVFileTypeAppleM4V,
codec: AVVideoCodecH264,
deleteFileIfExists: true)
}

var assetWriterInputSettings: [String : Any] {
return [
AVVideoCodecKey: codec,
AVVideoWidthKey: videoSize.width,
AVVideoHeightKey: videoSize.height
]
}
var sourcePixelBufferAttributes: [String : Any] {
return [
kCVPixelBufferPixelFormatTypeKey as String: NSNumber(value: kCVPixelFormatType_32ARGB),
kCVPixelBufferWidthKey as String: videoSize.width,
kCVPixelBufferHeightKey as String: videoSize.height
]
}
}
}

Loading