I am running the streamio-ffmpeg gem in my Ruby code here to operate the FFMPEG command.
Setting a Webm with codec VP9 that has alpha transparent frames in it as the input, I want to change the resolution from 1080p to 720p and preserve the alpha transparent frames when outputting to the same format/codec.
I've tried it several different ways, but every time it outputs with a black background where the alpha transparent background should be, but ffprobe shows that ALPHA_MODE is set to 1.
Here's the command that streamio-ffmpeg tells the system:
["/usr/local/bin/ffmpeg", "-y", "-i", "part1.webm", "-s", "1920x1080", "-aspect", "1.7777777777777777", "videos/movie_transparent_1920x1080.webm"]
This one should have been exactly the same as the original, since the original resolution WAS 1080p. The resulting file is actually black background instead of transparent.
Here's my Ruby code:
def process_alpha_transparency(output)
render_res = []
case @height
when 1080..2160
render_res.append("1920x1080", "1280x720", "852x480")
when 720..1079
render_res.append("1280x720", "852x480")
when 480..719
render_res.append("852x480")
when 0..479
render_res.append(@resolution)
end
formats = ["webm", "mov"]
combined_time_start = Time.now
render_res.each do |res|
formats.each do |format|
puts "Rendering a #{res} resolution version."
if format == "webm"
options = {
resolution: res
}
time_start = Time.now
@movie.transcode("videos/#{output}_transparent_#{res}.#{format}", options)
time_elapsed = Time.now - time_start
puts "Te resolution rendering completed in #{time_elapsed.to_i.to_s} seconds."
end
end
end
combined_elapsed_time = Time.now - combined_time_start
puts "The process completed in #{combined_elapsed_time.to_i.to_s} seconds."
end