Skip to contents

Returns the time, in seconds from the start of the recording, at which each observation begins. A recording with its own times is read from them: libTAS stores the length of every frame, and JPC-RR and openMSX store a timestamp with every event. A recording of frames or game tics without times is placed on the frame rate of recording_info(), where it has one. Observations that are controller polls or game updates have no time in the file, and their number per frame is not fixed; they return NA.

Usage

observation_time(movie, fallback_rate = NA)

Arguments

movie

A replayr_movie or replayr_poll_stream returned by read_movie() or a format-specific reader.

fallback_rate

Frame rate, in frames per second, to use where neither the recording nor its platform gives one, such as 60 or 50 for a Nintendo 64 recording. The default NA assumes none.

Value

Numeric vector with one entry per observation, in seconds; NA where the recording fixes no time.

Details

After a selection with [, times still count from the start of the file. A frame rate that recording_info() reports as nominal for the platform is that of the original console; an emulator that ran at another speed, or a game that lags, does not change the times returned here.

Examples

movie <- read_movie(system.file("extdata", "sample.fm2", package = "replayr"))
range(observation_time(movie))
#> [1]  0.00000 59.88471
# Seconds for which A is held.
sum(diff(observation_time(movie))[player(movie)[-1, "a"]])
#> [1] 7.471029