I use GoPros to look at sightings data of different species in an area. As the GoPro separates a video into several clips (named GOPR###, GP01###, GP02###, ... for a single "Deployment".), I’m trying to combine the results of these multiple clips into that of a single video.

I’ve created an example dataset below.

library(lubridate)
library(tidyverse)

set.seed(98765)
Sighting_Test <- data.frame(
  Date = rep(seq(as.POSIXct("01-01-2018", format="%d-%m-%Y"), as.POSIXct("04-01-2018", format="%d-%m-%Y"), by="day"), each=10),
  Deployment = as.factor(c(rep(1:4, each=10))),
  Clip = c(rep(c("GOPR888", "GP01888"), each=5), 
            rep(c("GOPR890", "GP01890"), each=5), 
            rep(c("GOPR895", "GP01895"), each=5), 
            rep(c("GOPR901", "GP01901"), each=5)),
  Start = ms(rep("00:00", 40)),
  Finish = ms(rep(c("17:35", "13:45"), each=5, 4)), 
  Timestamp = ms(rep(c("00:00", "00:05", "00:10", "00:15", "00:20"), 8)), 
  SpA = floor(runif(40, 0,10)),
  SpB = floor(runif(40, 0,10)),
  SpC = floor(runif(40, 0,10)) 
)

As I’m keeping track of species at each timestamp, what I’m looking for is a dataset that adjusts the timestamp of later clips (GP01, GP02,…) to keep in mind the finishing time of the previous clip.

Thus:

      Date Deployment   Video Start  Finish Timestamp SpA SpB SpC
2018-01-01          1 GOPR888    0S 17M 35S        0S   1   7   0
2018-01-01          1 GOPR888    0S 17M 35S        5S   2   9   5
2018-01-01          1 GOPR888    0S 17M 35S       10S   1   5   6
2018-01-01          1 GOPR888    0S 17M 35S       15S   1   3   9
2018-01-01          1 GOPR888    0S 17M 35S       20S   6   7   8
2018-01-01          1 GP01888    0S 13M 45S        0S   3   9   8
2018-01-01          1 GP01888    0S 13M 45S        5S   4   5   2
2018-01-01          1 GP01888    0S 13M 45S       10S   3   3   0
2018-01-01          1 GP01888    0S 13M 45S       15S   6   4   7

Becomes:

      Date Deployment   Video Start  Finish Timestamp SpA SpB SpC
2018-01-01          1 GOPR888    0S 17M 35S        0S   1   7   0
2018-01-01          1 GOPR888    0S 17M 35S        5S   2   9   5
2018-01-01          1 GOPR888    0S 17M 35S       10S   1   5   6
2018-01-01          1 GOPR888    0S 17M 35S       15S   1   3   9
2018-01-01          1 GOPR888    0S 17M 35S       20S   6   7   8
2018-01-01          1 GP01888    0S 13M 45S   17M 35S   3   9   8
2018-01-01          1 GP01888    0S 13M 45S   17M 40S   4   5   2
2018-01-01          1 GP01888    0S 13M 45S   17M 45S   3   3   0
2018-01-01          1 GP01888    0S 13M 45S   17M 50S   6   4   7

(As the finish time of the previous clip is 17:35, the timestamp becomes 17:35 + 00:05 = 17:40)

Previously I've done this manually, but as this is incredibly time consuming, I'm looking for something more automated. And because I've done it manually in the past, I also have no idea where to start to look for a solution.

The "Start", "Finish" and "Timestamp" columns are classified as a hm-period object, however, as the data will come in as ##:## text, I'm open to use another format.

0 Answers