ropensci / av

Working with Video in R
https://docs.ropensci.org/av
Other
92 stars 10 forks source link

Cluttered Background in Conversion #36

Closed ghost closed 3 years ago

ghost commented 3 years ago

Thanks for this lovely package. Much appreciated. I am trying to convert mp4 to gif. Output file is a bit cluttered in terms of background. Can we also add delay argument in the function?

library(av)
av_encode_video("demo.mp4", output = "output.gif", framerate = 10, verbose = TRUE)
jeroen commented 3 years ago

I don't think there is much I can do about the gif encoder in the bindings.

An alternative encoder is available in the magick package. The image_animate() function has a delay parameter:

library(magick)
demo <- image_read_video("demo.mp4")
# demo <- image_animate(demo)
image_write(demo, "demo.gif")

# or alternatively using gifski:
image_write_gif(demo, "demo.gif")

Yet another alternative would be to use av_video_images() to extract png files and then convert those directly to gif using the gifski package.

ghost commented 3 years ago

Thanks for the alternative solution. Works like a charm. Much appreciated!