dv_create_video: Make a self-contained video file from a playlist

Description Usage Arguments Details Value See Also Examples

View source: R/convert.R

Description

Requires that ffmpeg be available on the system path. Note that the processing of each clip is done inside of a future_lapply call, and so you can have this part of the processing done in parallel by setting an appropriate futures plan before calling this function.

Usage

1
dv_create_video(playlist, filename, subtitle_column = NULL)

Arguments

playlist

data.frame: a playlist as returned by dv_video_playlist. Note that only local video sources are supported

filename

string: file to write to. If not specified (or NULL), a file in the temporary directory will be created. If filename exists, it will be overwritten. The extension of filename will determine the output format

subtitle_column

string: if not NULL, a subtitle file will be produced using the contents of this column (in the playlist) as the subtitle for each clip. The subtitle file will have the same name as filename but with extension ".srt"

Details

This function is experimental. In particular it is unlikely to work well with all video formats, and especially if the playlist comprises clips from different videos with different resolution/encoding/etc.

Value

A list with the filenames of the created video and subtitle files.

See Also

dv_video_playlist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
  my_playlist <- dv_video_playlist(..., type = "local")
  video_file <- dv_create_video(my_playlist)
  browseURL(video_file[[1]])

  ## run in parallel, with the scouted codes as subtitles
  library(dplyr)
  library(future.apply)
  plan(multisession)
  ## note that the example file doesn't have a video associated with it, so
  ##  this example won't actually work in practice
  x <- read_dv(dv_example_file())
  ## fudge the video entry
  x$meta$video <- tibble(camera = "Camera0", file = "~/my_video.mp4")
  ## make the playlist
  my_playlist <- dv_video_playlist(
    x$plays %>% dplyr::filter(skill == "Reception") %>% slice(1:10),
    meta = x$meta, extra_cols = "code")
  ## create the video and subtitles files
  video_file <- dv_create_video(my_playlist, subtitle_column = "code")

## End(Not run)

scienceuntangled/dvideo documentation built on March 13, 2020, 6:50 p.m.