Skip to content

Commit

Permalink
Swift Package Manager rewrite.
Browse files Browse the repository at this point in the history
  • Loading branch information
sturmen committed Jan 23, 2024
1 parent e924f73 commit 19281c9
Show file tree
Hide file tree
Showing 19 changed files with 487 additions and 691 deletions.
21 changes: 17 additions & 4 deletions .gitignore
@@ -1,3 +1,17 @@
**/.DS_Store
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
Expand Down Expand Up @@ -37,9 +51,9 @@ playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
Packages/
Package.pins
Package.resolved
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
Expand Down Expand Up @@ -88,4 +102,3 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

28 changes: 28 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,28 @@
{
"configurations": [
{
"type": "lldb",
"request": "launch",
"sourceLanguages": [
"swift"
],
"args": [],
"cwd": "${workspaceFolder:mvhevcsplit}",
"name": "Debug spatial-media-kit-tool",
"program": "${workspaceFolder:mvhevcsplit}/.build/debug/spatial-media-kit-tool",
"preLaunchTask": "swift: Build Debug spatial-media-kit-tool"
},
{
"type": "lldb",
"request": "launch",
"sourceLanguages": [
"swift"
],
"args": [],
"cwd": "${workspaceFolder:mvhevcsplit}",
"name": "Release spatial-media-kit-tool",
"program": "${workspaceFolder:mvhevcsplit}/.build/release/spatial-media-kit-tool",
"preLaunchTask": "swift: Build Release spatial-media-kit-tool"
}
]
}
14 changes: 14 additions & 0 deletions Package.resolved
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
}
}
],
"version" : 2
}
38 changes: 38 additions & 0 deletions Package.swift
@@ -0,0 +1,38 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SpatialMediaKit",
platforms: [
.macOS(.v14)
],
products: [
.executable(name: "spatial-media-kit-tool", targets: ["SpatialMediaKitTool"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0")
],
targets: [
.executableTarget(
name: "SpatialMediaKitTool",
dependencies: [
"SpatialMediaKit",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]),
.target(
name: "SpatialMediaKit",
dependencies: ["SpatialMediaKitObjC"]),
.target(
name: "SpatialMediaKitObjC",
publicHeadersPath: "headers"),
.testTarget(
name: "SpatialMediaKitTests",
dependencies: ["SpatialMediaKit"],
resources: [
.copy("TestData/spatial_video.mov")
]
),
]
)
42 changes: 32 additions & 10 deletions README.md
@@ -1,16 +1,16 @@
# mvhevcsplit
# SpatialMediaKit

Split a MV-HEVC file into separate left and right ProRes files.
A utility for transforming spatial media.

## Purpose

As of January 2024, Apple's MV-HEVC format for stereoscopic video is very new and barely supported by anything. However, there are millions of iPhones (iPhone 15 Pro/Pro Max) that can capture spatial video already. There was no available FOSS tool capable of splitting the stereo pair, especially not in formats suited for post-production.

## Features

There is only one feature: it takes an MV-HEVC file and outputs the left and right eyes as separate files in the current directory. The output format is ProRes 422 HQ, video only. The user is expected to be familiar with tools such as ffmpeg for all other needs, including remuxing the audio back in.
Today, there is only one feature: `Split`. It takes an MV-HEVC file and outputs the left and right eyes as separate files in the current directory. The output format is ProRes 422 HQ, video only. The user is expected to be familiar with tools such as ffmpeg for all other needs, including remuxing the audio back in.

Compared to similar tools:, `mvhevcsplit` has the following advantages:
Compared to similar tools:, `SpatialMediaKit` has the following advantages:

- Free as in speech and free as in beer. Other tools are proprietary and often charge fees.
- "Visually lossless" (Apple's words) preservation of the original video streams. Other tools re-encode using lossy HEVC compression in side-by-side, leading to generational quality loss.
Expand All @@ -19,21 +19,33 @@ Compared to similar tools:, `mvhevcsplit` has the following advantages:

## Requirements

This has been tested on an M1 Max MacBook Pro running macOS 14.2.1 with [Pro Video Formats 2.3](https://support.apple.com/kb/DL2100?viewlocale=en_US&locale=en_US). Hopefully other configurations work, but your mileage may vary.
This has been tested on an M1 Max MacBook Pro running macOS 14.2.1. Hopefully other configurations work, but your mileage may vary.

## Installation

1. Download `mvhevcsplit` from the releases
2. In Terminal, navigate to where you placed the binary and mark it as executable: `chmod +x mvhevcsplit`
3. Copy into your PATH (for example: `sudo cp mvhevcsplit /usr/local/bin`), or leave it in a working directory
1. Download `spatial-media-kit-tool` from the [releases page](https://github.com/sturmen/SpatialMediaKit/releases)
2. In Terminal, navigate to where you placed the binary and mark it as executable: `chmod +x spatial-media-kit-tool`
3. Copy into your PATH (for example: `sudo cp spatial-media-kit-tool /usr/local/bin`), or leave it in a working directory

In the future I may also try to figure out how to get this added to Homebrew.

## Usage

In Terminal: `mvhevcsplit 1920 1080 MOV_0001.MOV`
### `split`

`output_left.mov` and `output_right.mov`, if they already exist, **will be deleted** and then new files with those names will be written to the current directory.
```text
OVERVIEW: Split a single MV-HEVC input into left and right video files.
USAGE: spatial-media-kit-tool split --input-file <input-file> [--output-dir <output-dir>]
OPTIONS:
-i, --input-file <input-file>
The spatial media file to split.
-o, --output-dir <output-dir>
The output directory for the resulting files. If not provided, the current directory will be used.
--version Show the version.
-h, --help Show help information.
```

## Contributing

Expand All @@ -45,6 +57,16 @@ This would not have been possible without [this blog post](https://www.finnvoorh

## Changelog

### v0.0.3-alpha (2024-01-22)

- Renamed project to "SpatialMediaKit"
- Huge refactor, now based on Swift Package Manager
- Automatically determines output resolution based on input resolution
- Reads the source file once and writes both eyes, cutting processing time in half.
- Allows choosing output directory.
- Revamped CLI.
- Added test case

### v0.0.2-alpha (2024-01-21)

Have user specify output dimensions.
Expand Down
17 changes: 17 additions & 0 deletions Sources/SpatialMediaKit/MediaError.swift
@@ -0,0 +1,17 @@
//
// MediaError.swift
// SpatialMediaKit
//
// Created by Nicholas Tinsley on 1/22/24.
//

import Foundation

enum MediaError: Error {
case invalidMediaInput
case noVideoTracksFound
case couldNotReadSample
case couldNotParse
case timeoutError
case createOutputError
}

0 comments on commit 19281c9

Please sign in to comment.