Uniformly shift subtitle times

srt_shift(x, seconds)

Arguments

x

A subtitle data frame from read_srt().

seconds

The number of seconds to shift the start and end time.

Value

The numeric start times uniformly shifted by some amount.

Details

Here is a workflow of how a linear srt file is shifted in R.

read_srt(file) %>%
  srt_shift(2.1) %>%
  write_srt(file)

Examples

# shift all start and stop by a some time
x <- read_srt(srt_example(), collapse = " ")
srt_shift(x, 1.234)
#> # A tibble: 2,268 × 4
#>        n start   end subtitle                           
#>    <int> <dbl> <dbl> <chr>                              
#>  1     1  86.4  89.2 I owe everything to George Bailey. 
#>  2     2  89.7  91.5 Help him, dear Father.             
#>  3     3  91.9  95.0 Joseph, Jesus and Mary,            
#>  4     4  95.0  97.7 help my friend Mr. Bailey.         
#>  5     5  98.1 101.  Help my son George tonight.        
#>  6     6 102.  103.  He never thinks about himself, God.
#>  7     7 104.  105.  That's why he's in trouble.        
#>  8     8 105.  107.  George is a good guy.              
#>  9     9 108.  109.  Give him a break, God.             
#> 10    10 109.  111.  I love him, dear Lord.             
#> # ℹ 2,258 more rows