ts2frame: Convert timestamps to frame numbers

Description Usage Arguments Examples

View source: R/misc.R

Description

Provide the frame rate to use to create break points from millisecond time data

Usage

1
2
ts2frame(x, fps = 30, tstart = 0, tend, chunked = FALSE,
  warn = TRUE)

Arguments

x

Vector of timestamps

fps

Frames per second of the video source. Defaults to 30 Frames Per Second. The smaller the value, the more likely two events will be chunked in the same frame.

tstart

Start timestamp. Anything below start will not be converted.

tend

End timestamp. Anything above will be NA. Defaults to max of x if not set.

chunked

If set to TRUE, will return a time back to you instead of frame number, but the chunked/cut value corresponding to that frame.

warn

Turn on/off warnings for NAs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# sequence of milliseconds
x <- seq(1, 1009, 12)

# 30 fps video
ts2frame(x, fps=30)

# first frames are NA until start frame is encountered
ts2frame(x, fps=29.97, tstart=333)

# compare chunked time to actual time
cbind(sprintf("%.2f", ts2frame(x, tstart=100, tend=1000, fps=30, chunked=TRUE)), x)

iamamutt/mejr documentation built on May 18, 2019, 1:27 a.m.