Skip to content

Instantly share code, notes, and snippets.

View denrou's full-sized avatar

Denis Roussel denrou

  • Centreon
  • Québec
View GitHub Profile
@denrou
denrou / timelapse.md
Created May 13, 2018 19:14 — forked from porjo/timelapse.md
ffmpeg time-lapse

Convert sequence of JPEG images to MP4 video

ffmpeg -r 24 -pattern_type glob -i '*.JPG' -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4

  • -r 24 - output frame rate
  • -pattern_type glob -i '*.JPG' - all JPG files in the current directory
  • -i DSC_%04d.JPG - e.g. DSC_0397.JPG
  • -s hd1080 - 1920x1080 resolution

Slower, better quality

@denrou
denrou / shift.R
Last active May 2, 2018 14:47
Add lags to multiple column in a dataframe
shift <- function(x, ..., shifts = 1, suffix = "lag") {
vars <- unname(tidyselect::vars_select(names(x), !!!rlang::quos(...)))
combinations <- expand.grid(var = vars, shift = shifts, stringsAsFactors = FALSE)
shift_cols <- purrr::pmap_dfc(combinations, function(var, shift) {
new_var <- glue::glue("lag_{var}_{shift}")
tibble::tibble(!!new_var := dplyr::lag(x[[var]], shift))
})
dplyr::bind_cols(x, shift_cols)
}