Skip to content

Commit

Permalink
Merge pull request #24 from Synopsis/development
Browse files Browse the repository at this point in the history
Beta 3
  • Loading branch information
vade authored Oct 24, 2024
2 parents b4bca6c + 310c10f commit 4294de6
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "OpenTimelineIO-Reader/OpenTimelineIO_Reader.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = "\"OpenTimelineIO-Reader/Preview Content\"";
DEVELOPMENT_TEAM = SHG3AW6YV7;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -201,7 +201,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = "1.0 Beta 2";
MARKETING_VERSION = "1.0 Beta 3";
PRODUCT_BUNDLE_IDENTIFIER = "ai.ozu.OpenTimelineIO-Reader";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand All @@ -220,7 +220,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "OpenTimelineIO-Reader/OpenTimelineIO_Reader.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = "\"OpenTimelineIO-Reader/Preview Content\"";
DEVELOPMENT_TEAM = SHG3AW6YV7;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -243,7 +243,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = "1.0 Beta 2";
MARKETING_VERSION = "1.0 Beta 3";
PRODUCT_BUNDLE_IDENTIFIER = "ai.ozu.OpenTimelineIO-Reader";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class OpenTimelineIO_ReaderDocument: FileDocument, ObservableObject
queue: .main,
using: { [weak self] time in

print("update current time \(time)")
self?.currentTime = time.toOTIORationalTime()

})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct ContentView: View
.lineLimit(1)
.font(.system(size: 10))

Slider(value: $secondsToPixels, in: 10...1000)
Slider(value: $secondsToPixels, in: 1...1000)
.controlSize(.mini)
.frame(width: 200)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,20 @@ struct TimelineView : View {
.frame(height: 40)
.offset(x:100)
//
// Divider()

ForEach(0..<videoTracks.count, id: \.self) { index in

let track = videoTracks[index]
// Reverse
let track = videoTracks[(videoTracks.count - 1 ) - index]

TrackView(track: track,
backgroundColor: Color("VideoTrackBaseColor"),
secondsToPixels: self.$secondsToPixels,
selectedItem: self.$selectedItem )
}

Divider()

ForEach(0..<audioTracks.count, id: \.self) { index in

let track = audioTracks[index]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,29 @@ import TimecodeKit
extension Clip
{
// see https://opentimelineio.readthedocs.io/en/latest/tutorials/time-ranges.html
func toAVAssetAndMapping(baseURL:URL? = nil, useTimecode:Bool = true, rescaleToAsset:Bool = true) throws -> (asset:AVAsset, timeMaping:CMTimeMapping)?
func toAVAssetAndMapping(baseURL:URL? = nil, trackType:AVMediaType, useTimecode:Bool = true, rescaleToAsset:Bool = true) throws -> (asset:AVAsset, timeMaping:CMTimeMapping)?
{
guard
let externalReference = self.mediaReference as? ExternalReference,
let asset = externalReference.toAVAsset(baseURL: baseURL)
// let parent = self.parent as? Item

let asset:AVURLAsset

if let externalReference = self.mediaReference as? ExternalReference,
let maybeAsset = externalReference.toAVAsset(baseURL: baseURL)
{

guard !maybeAsset.tracks(withMediaType: trackType).isEmpty else { return nil }

asset = maybeAsset
}
else
{
return nil
//see AWS Picchu Edit - Premiere cant import either?
//we have a generator or just a dead reference?
let missingMediaURL = Bundle.main.url(forResource: "MediaNotFound", withExtension: "mp4")!
let missingAsset = AVURLAsset(url: missingMediaURL)

guard !missingAsset.tracks(withMediaType: trackType).isEmpty else { return nil }

asset = missingAsset
}

var timeRangeInAsset = try self.trimmedRange()
Expand Down Expand Up @@ -67,6 +81,22 @@ extension Clip
// let timeRangeInParentTrackNoTC = timeRangeInParentTrack.startTime - startTimeCode.cmTimeValue.toOTIORationalTime()
// timeRangeInParentTrack = TimeRange(startTime: timeRangeInParentTrackNoTC, duration: timeRangeInParentTrack.duration)
}

// We might find ourselves with a situation where the timecode of the source media in the timeline existed, but we are working with proxies without TC
// This means we need to deduce if the time in OTIO differs from the assets and adjust accordingly
else if let firstVideoTrackStart = asset.tracks(withMediaType: .video).first
{
let assetAvailableTime = try self.availableRange()

// If our start times differ...
if firstVideoTrackStart.timeRange.start.toOTIORationalTime() != assetAvailableTime.startTime
{
let timeDifference = assetAvailableTime.startTime - firstVideoTrackStart.timeRange.start.toOTIORationalTime()

let assetStartTimeNoTC = timeRangeInAsset.startTime - timeDifference
timeRangeInAsset = TimeRange(startTime: assetStartTimeNoTC, duration: timeRangeInAsset.duration)
}
}
}
catch Timecode.MediaParseError.missingOrNonStandardFrameRate
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension ExternalReference
if FileManager.default.fileExists(atPath: path)
{
let sourceURL = URL(filePath: path)
return AVURLAsset(url: sourceURL)
return self.tryLoadAssetAtResolvedURL(url: sourceURL)
}
else if let baseURL = baseURL
{
Expand All @@ -62,7 +62,7 @@ extension ExternalReference

if FileManager.default.fileExists(atPath: sourceURL.path(percentEncoded: false))
{
return AVURLAsset(url: sourceURL)
return self.tryLoadAssetAtResolvedURL(url: sourceURL)
}

// we cant have a base url with a relative path to root dir...
Expand All @@ -73,12 +73,56 @@ extension ExternalReference
var sourceURL = baseURL.appending(path: pathWithoutRoot )
if FileManager.default.fileExists(atPath: sourceURL.path(percentEncoded: false))
{
return AVURLAsset(url: sourceURL)
return self.tryLoadAssetAtResolvedURL(url: sourceURL)
}
}
}

return nil
let missingMediaURL = Bundle.main.url(forResource: "MediaNotFound", withExtension: "mp4")!

return AVURLAsset(url: missingMediaURL)
}

fileprivate func tryLoadAssetAtResolvedURL(url:URL) -> AVURLAsset
{
// do some very simple semantics to see if theres a chance we can load the asset

let supported:Bool

switch url.pathExtension
{
case "mp4":
supported = true
case "mov":
supported = true
case "m4v":
supported = true


case "m4a":
supported = true
case "mp3":
supported = true
case "aiff":
supported = true
case "wav":
supported = true


default:
supported = false
}

if supported
{
return AVURLAsset(url: url)
}

let notSupportedMedia = Bundle.main.url(forResource: "MediaNotSupported", withExtension: "mp4")!

return AVURLAsset(url: notSupportedMedia)

}

}

Loading

0 comments on commit 4294de6

Please sign in to comment.