Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

framerate less than 1 does not work for audio longer than 1 minute #37

Open
slfan2013 opened this issue May 24, 2021 · 0 comments
Open

Comments

@slfan2013
Copy link

If framerate is less than 1, demo.mp4 does not play for audio longer than 1 minute.

If framerate is greater than 1, demo.mp4 does play for audio longer than 1 minute.

If framerate is less than 1, demo.mp4 does play for audio shorter than 1 minute.

Please see the following code. If using system.file('samples/Synapsis-Wonderland.mp3', package='av', mustWork = TRUE) , it works. If using the downloaded mp3, it does not.

library(av)
output = "demo.mp4"
width = 960
height = 720
framerate = 0.1 # I set framerate less than 1.
verbose = TRUE
wonderland <- system.file('samples/Synapsis-Wonderland.mp3', package='av', mustWork = TRUE) # This audio is less than 1 minute. Using this file, we CAN play "demo.mp4".
download.file('https://github.com/slfan2013/MetNorm/raw/master/test.mp3', destfile = 'test.mp3',mode = "wb")
wonderland = 'test.mp3'  # This audio is longer than 1 minute. Using this file, we CANNOT play "demo.mp4".
info <- av_media_info(wonderland)
len <- framerate * round(info$duration)
res <- round(72 * min(width, height) / 480)

# RColorBrewer::brewer.pal(12,"Set3")
col <- c("#8DD3C7", "#FFFFB3", "#BEBADA", "#FB8072", "#80B1D3", "#FDB462",
         "#B3DE69", "#FCCDE5", "#D9D9D9", "#BC80BD", "#CCEBC5", "#FFED6F")
video <- av_capture_graphics(output = output,  audio = wonderland, {
  for(i in seq_len(len)){
    if(as.logical(verbose))
      cat(i)
    graphics::hist(stats::rnorm(100), col = col, main = i)
  }
  if(as.logical(verbose))
    cat("done!\n", file = stderr())
}, width = width, height = height, res = res, framerate = framerate, verbose = verbose)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant