Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
PBJVision: write metadata into output files
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Piemonte committed Sep 5, 2013
1 parent 60dc842 commit 17eb875
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion Source/PBJVision.m
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,31 @@ - (BOOL)canCaptureVideo
return [self supportsVideoCapture] && [self isActive] && !_flags.changingModes && isDiskSpaceAvailable;
}

- (NSArray *)_metadataArray
{
UIDevice *currentDevice = [UIDevice currentDevice];

// device model
AVMutableMetadataItem *modelItem = [[AVMutableMetadataItem alloc] init];
[modelItem setKeySpace:AVMetadataKeySpaceCommon];
[modelItem setKey:AVMetadataCommonKeyModel];
[modelItem setValue:[currentDevice localizedModel]];

// software
AVMutableMetadataItem *softwareItem = [[AVMutableMetadataItem alloc] init];
[softwareItem setKeySpace:AVMetadataKeySpaceCommon];
[softwareItem setKey:AVMetadataCommonKeySoftware];
[softwareItem setValue:[NSString stringWithFormat:@"%@ %@ PBJVision", [currentDevice systemName], [currentDevice systemVersion]]];

// creation date
AVMutableMetadataItem *creationDateItem = [[AVMutableMetadataItem alloc] init];
[creationDateItem setKeySpace:AVMetadataKeySpaceCommon];
[creationDateItem setKey:AVMetadataCommonKeyCreationDate];
[creationDateItem setValue:[NSString PBJformattedTimestampStringFromDate:[NSDate date]]];

return @[modelItem, softwareItem, creationDateItem];
}

- (void)startVideoCapture
{
if (![self _canSessionCaptureWithOutput:_currentOutput]) {
Expand Down Expand Up @@ -923,7 +948,8 @@ - (void)startVideoCapture
return;
}

// TODO: create metadata and add to _assetWriter.metadata
NSArray *metadata = [self _metadataArray];
_assetWriter.metadata = metadata;

[self _enqueueBlockOnMainQueue:^{
if ([_delegate respondsToSelector:@selector(visionDidStartVideoCapture:)])
Expand Down

0 comments on commit 17eb875

Please sign in to comment.