Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show record timer while making video

I had implemented the concept of AVCaptureSession for recording video.

-(void)startRecordingWithOrientation:(AVCaptureVideoOrientation)videoOrientation 
{

    AVCaptureConnection *videoConnection = [AVCamUtilities   
                                           connectionWithMediaType:AVMediaTypeVideo  
                                           fromConnections:[[self movieFileOutput] connections]];
    if ([videoConnection isVideoOrientationSupported])
        [videoConnection setVideoOrientation:videoOrientation];

    [[self movieFileOutput] startRecordingToOutputFileURL:[self outputFileURL]  
    recordingDelegate:self];
 } 

It is recording the video properly but the recording timer in not there on the screen. Anyone has an idea that how to show timer while making video.

Thanks in advance.

like image 279
Sudha Tiwari Avatar asked Mar 06 '14 10:03

Sudha Tiwari


People also ask

What is a recording timer?

(Recording Timer allows students to conduct scientific inquiry about linear kinematics by creating a record of the motion of an object with respect to time.


1 Answers

I use add a UILabel to the view where is presented the video while is recording and I use this code to show the record time

@property (weak, nonatomic) IBOutlet UILabel *labelTime;

@property(nonatomic, strong) NSTimer *timer;
@property(nonatomic) int timeSec;
@property(nonatomic) int timeMin;

//Method to start recording

- (void)startRecord {
    self.timeMin = 0;
    self.timeSec = 0;

    //String format 00:00
    NSString* timeNow = [NSString stringWithFormat:@"%02d:%02d", self.timeMin, self.timeSec];
    //Display on your label
    //[timeLabel setStringValue:timeNow];
    self.labelTime.text= timeNow;

    self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerTick:) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];

    //Start recording
    [movieFileOutput startRecordingToOutputFileURL:outputURL recordingDelegate:self];

}


//Event called every time the NSTimer ticks.
- (void)timerTick:(NSTimer *)timer {
    self.timeSec++;
    if (self.timeSec == 60)
    {
        self.timeSec = 0;
        self.timeMin++;
    }
    //String format 00:00
    NSString* timeNow = [NSString stringWithFormat:@"%02d:%02d", self.timeMin, self.timeSec];
    //Display on your label
    self.labelTime.text= timeNow;
}
like image 199
Fran Martin Avatar answered Nov 03 '22 01:11

Fran Martin