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)
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.