7
7
//
8
8
9
9
#import " TCMCommandLineUtility.h"
10
- #import < QTKit/QTKit .h>
10
+ #import < QTKit/QTKitDefines .h>
11
11
#import " TCMCaptureManager.h"
12
12
#import " FSArguments.h"
13
13
#import " FSArguments_Coalescer_Internal.h"
@@ -215,17 +215,6 @@ static void exception_handler(NSException *anException) {
215
215
S_defaultHandler (anException);
216
216
}
217
217
218
- @interface QTCaptureDevice (SightSnapAdditions)
219
- - (NSString *)localizedUniqueDisplayName ;
220
- @end
221
-
222
- @implementation QTCaptureDevice (SightSnapAdditions)
223
- - (NSString *)localizedUniqueDisplayName {
224
- NSString *result = [NSString stringWithFormat: @" %@ [%@ - %@ ]" , self .localizedDisplayName, self .modelUniqueID, self .uniqueID];
225
- return result;
226
- }
227
- @end
228
-
229
218
@interface AVCaptureDevice (SightSnapAdditions)
230
219
- (NSString *)localizedUniqueDisplayName ;
231
220
@end
@@ -374,7 +363,7 @@ - (int)run {
374
363
375
364
NSInteger terminalWidth = 80 ;
376
365
if ([package booleanValueForSignature: help]) {
377
- puts (" sightsnap v0.6 by @monkeydom" );
366
+ puts (" sightsnap v0.6.1 by @monkeydom" );
378
367
puts (" usage: sightsnap [options] [output[.jpg|.png]] [options]" );
379
368
puts (" " );
380
369
puts (" Default output filename is signtsnap.jpg - if no extension is given, jpg is used.\n If you add directory in front, it will be created." );
@@ -539,41 +528,51 @@ - (NSURL *)nextFrameFileURL {
539
528
540
529
- (void )captureImage {
541
530
self.lastFrameFireDate = [NSDate new ];
542
-
531
+ static NSDateFormatter *dateFormatter = nil ;
532
+ if (!dateFormatter) {
533
+ dateFormatter = [NSDateFormatter new ];
534
+ dateFormatter.timeStyle = NSDateFormatterMediumStyle;
535
+ dateFormatter.dateStyle = NSDateFormatterShortStyle;
536
+ }
543
537
TCMCaptureManager *captureManager = [TCMCaptureManager captureManager ];
544
- if (self.shouldTimeStamp ) {
545
- if (!self.timeStampDate ) {
538
+ BOOL shouldTimeStamp = self.shouldTimeStamp ;
539
+ if (shouldTimeStamp) {
540
+ if (!self.timeStampDate && self.onlyOneTimeStamp ) {
546
541
self.timeStampDate = [NSDate date ];
547
- } else if (!self.onlyOneTimeStamp ) {
548
- self.timeStampDate = self.lastFrameFireDate ;
549
542
}
550
- NSDateFormatter *dateFormatter = [NSDateFormatter new ];
551
- dateFormatter.timeStyle = NSDateFormatterMediumStyle;
552
- dateFormatter.dateStyle = NSDateFormatterShortStyle;
553
- self.topLeftText = [dateFormatter stringFromDate: self .timeStampDate];
554
543
}
544
+ NSDate *timeStampDate = self.timeStampDate ;
545
+
555
546
if (self.topLeftText || self.titleText || self.commentText ) {
556
-
547
+ NSString *fontName = self.fontName ;
548
+ CGFloat fontSize = self.fontSize ;
549
+
557
550
SIGHTCaption *topLeftCaption;
558
551
if (self.topLeftText ) {
559
- SIGHTCaption *caption = [SIGHTCaption captionWithText: self .topLeftText position: kSIGHTCaptionPositionTopLeft fontName: self . fontName fontSize: self . fontSize];
552
+ SIGHTCaption *caption = [SIGHTCaption captionWithText: self .topLeftText position: kSIGHTCaptionPositionTopLeft fontName: fontName fontSize: fontSize];
560
553
topLeftCaption = caption;
561
554
}
562
555
SIGHTCaption *topRightCaption;
563
556
if (self.titleText ) {
564
- SIGHTCaption *caption = [SIGHTCaption captionWithText: self .titleText position: kSIGHTCaptionPositionTopRight fontName: self . fontName fontSize: self . fontSize];
557
+ SIGHTCaption *caption = [SIGHTCaption captionWithText: self .titleText position: kSIGHTCaptionPositionTopRight fontName: fontName fontSize: fontSize];
565
558
topRightCaption = caption;
566
559
}
567
560
568
561
SIGHTCaption *bottomLeftCaption;
569
562
if (self.commentText ) {
570
- SIGHTCaption *caption = [SIGHTCaption captionWithText: self .commentText position: kSIGHTCaptionPositionBottomLeft fontName: self . fontName fontSize: self . fontSize];
563
+ SIGHTCaption *caption = [SIGHTCaption captionWithText: self .commentText position: kSIGHTCaptionPositionBottomLeft fontName: fontName fontSize: fontSize];
571
564
bottomLeftCaption = caption;
572
565
}
573
- TCMCaptureQuartzAction drawAction = ^(CGContextRef ctx, CGRect aFrame) {
566
+ TCMCaptureQuartzAction drawAction = ^(CGContextRef ctx, CGRect aFrame, NSDate *frameTimestampDate ) {
574
567
CGFloat topRightCaptionFirstLineMargin = 0.0 ;
575
- if (topLeftCaption) {
576
- topRightCaptionFirstLineMargin = [topLeftCaption drawInContext: ctx frame: aFrame firstLineLessWidth: 0 ];
568
+ if (shouldTimeStamp) {
569
+ NSDate *date = timeStampDate;
570
+ if (!date) {
571
+ date = frameTimestampDate;
572
+ }
573
+ NSString *timeStampString = [dateFormatter stringFromDate: date];
574
+ SIGHTCaption *caption = [SIGHTCaption captionWithText: timeStampString position: kSIGHTCaptionPositionTopLeft fontName: fontName fontSize: fontSize];
575
+ topRightCaptionFirstLineMargin = [caption drawInContext: ctx frame: aFrame firstLineLessWidth: 0 ];
577
576
}
578
577
if (topRightCaption) {
579
578
[topRightCaption drawInContext: ctx frame: aFrame firstLineLessWidth: topRightCaptionFirstLineMargin];
@@ -600,6 +599,8 @@ - (void)didCaptureImage {
600
599
if (!self.firstCapturedFrameDate ) {
601
600
// [[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:[[NSUserNotification alloc] init]];
602
601
self.firstCapturedFrameDate = [NSDate date ];
602
+ // fix the hop at the first frame due to the skipframes
603
+ nextScheduleDate = [self .firstCapturedFrameDate dateByAddingTimeInterval: self .grabInterval];
603
604
} else {
604
605
NSTimeInterval maxGrabDuration = self.maxGrabDuration ;
605
606
if (maxGrabDuration > 0.0 ) {
0 commit comments