context("ffmpeg and av-based functions")
test_that("ffmpeg/av functions work", {
skip_if_not(ovideo:::ov_ffmpeg_ok(), "ffmpeg executable not found")
expect_message(chk <- ov_video_frame(system.file("extdata/2019_03_01-KATS-BEDS-clip.mp4", package = "ovideo"), t = 2+11/30, format = "png", method = "ffmpeg", debug = TRUE), "ov_video_frame using method 'ffmpeg'")
expect_gt(file.size(chk), 900e3)
ffmpeg_png_size <- file.size(chk)
expect_message(chk2 <- ov_video_frame(system.file("extdata/2019_03_01-KATS-BEDS-clip.mp4", package = "ovideo"), t = 2+11/30, format = "png", method = "auto", debug = TRUE), "ov_video_frame using method 'ffmpeg'")
expect_equal(file.size(chk2), file.size(chk))
expect_message(chk3 <- ov_video_frame(system.file("extdata/2019_03_01-KATS-BEDS-clip.mp4", package = "ovideo"), t = 2+11/30, format = "jpg", method = "ffmpeg", debug = TRUE), "ov_video_frame using method 'ffmpeg'")
expect_gt(file.size(chk3), 60e3)
expect_lt(file.size(chk3), ffmpeg_png_size)
ffmpeg_jpg_size <- file.size(chk3)
unlink(chk)
unlink(chk2)
unlink(chk3)
expect_message(chk <- ov_video_frame(system.file("extdata/2019_03_01-KATS-BEDS-clip.mp4", package = "ovideo"), t = 2+11/30, format = "jpg", method = "av", debug = TRUE), "ov_video_frame using method 'av'")
expect_gt(file.size(chk), 60e3)
expect_gt(file.size(chk), ffmpeg_jpg_size) ## av produces larger files?
expect_message(chk2 <- ov_video_frame(system.file("extdata/2019_03_01-KATS-BEDS-clip.mp4", package = "ovideo"), t = 2+11/30, format = "png", method = "av", debug = TRUE), "ov_video_frame using method 'av'")
expect_lt(abs(file.size(chk2) - ffmpeg_png_size), 10e3)
unlink(chk)
unlink(chk2)
chk <- ov_video_extract_clip(system.file("extdata/2019_03_01-KATS-BEDS-clip.mp4", package = "ovideo"), start_time = 1, duration = 3)
expect_true(file.exists(chk))
expect_gt(file.size(chk), 1e6)
imfiles <- ov_video_frames(chk)
expect_gte(length(imfiles), 90)
expect_true(file.exists(imfiles[1]))
## put back into video
chk2 <- ov_images_to_video(dirname(imfiles[1]))
expect_true(file.exists(chk2))
chk3 <- ov_images_to_video(image_files = imfiles)
expect_true(file.exists(chk3))
expect_lt(abs(file.size(chk2) - file.size(chk3)), 50e3) ## the two files should be about the same size
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.