ropensci / av

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

Scale argument in `av_video_convert` #42

Open stla opened 2 years ago

stla commented 2 years ago

Hello,

I use av to convert some GIFs to MOV files, in order to upload them to Youtube. If the width or the height of the GIF is not divisible by 2, that doesn't work. Therefore it would be nice if we could scale the video by 2. A possibility is:

av_video_convert <- function (video, output = "output.mp4", verbose = TRUE, scale = NULL) 
{
    info <- av_media_info(video)
    if (nrow(info$video) == 0) 
        stop("No suitable input video stream found")
    framerate <- info$video$framerate[1]
    audio <- if (length(info$audio) && nrow(info$audio)) 
        video
    vf <- if(is.null(scale))
        "null"
    else
        sprintf("scale=iw*%s:ih*%s", scale, scale)
    av_encode_video(input = video, audio = audio, output = output, 
        framerate = framerate, vfilter = vf, verbose = verbose)
}

Would you agree to make this change? (or I can do a PR if you want).

muschellij2 commented 2 years ago

Related to https://github.com/ropensci/av/issues/31 and https://github.com/ropensci/av/issues/2