- pad video properly when video is portrait or landscape...need to create tests for these
This commit is contained in:
parent
3b9abd43bf
commit
9d448738b2
@ -171,11 +171,15 @@ module BigBlueButton
|
||||
end
|
||||
|
||||
def self.portrait?(width, height)
|
||||
width < height
|
||||
larger_than_max?(width, height) and (width < height)
|
||||
end
|
||||
|
||||
def self.landscape?(width, height)
|
||||
width > height
|
||||
larger_than_max?(width, height) and (width > height)
|
||||
end
|
||||
|
||||
def self.larger_than_max?(width, height)
|
||||
(width > MAX_VID_WIDTH) and (height > MAX_VID_HEIGHT)
|
||||
end
|
||||
|
||||
# Calculate the height of the video to maintain 4/3 aspect ratio.
|
||||
@ -206,13 +210,15 @@ module BigBlueButton
|
||||
height = get_video_height(flv_in)
|
||||
anamorphic_factor = calc_anamorphic_factor(width, height)
|
||||
puts "factor=#{anamorphic_factor}, width=#{width}, height=#{height}"
|
||||
if (fits_640_by_480?(width, height))
|
||||
if (fits_640_by_480?(width, height))
|
||||
# The raw media is smaller than 640x480. Pad the sides of video to fit 640x480.
|
||||
padding = "-vf pad=#{MAX_VID_WIDTH}:#{MAX_VID_HEIGHT}:#{(MAX_VID_WIDTH - width)/2}:#{(MAX_VID_HEIGHT - height)/2}:FFFFFF"
|
||||
command = "ffmpeg -i #{flv_in} -aspect 4:3 -r 1000 -sameq #{padding} -vcodec flashsv #{flv_out}"
|
||||
puts command
|
||||
IO.popen(command)
|
||||
Process.wait
|
||||
elsif (width < MAX_VID_WIDTH) and (height > MAX_VID_HEIGHT)
|
||||
elsif (width < MAX_VID_WIDTH) and (height > MAX_VID_HEIGHT) or (portrait?(width, height)
|
||||
# Fit the video vertically and adjust the width then pad it to fit into 640x480 video.
|
||||
c_width = calc_width(anamorphic_factor)
|
||||
padding = MAX_VID_WIDTH - c_width
|
||||
puts "w < mW and h > mH : padding=#{padding}, c_width=#{c_width}"
|
||||
@ -220,20 +226,15 @@ module BigBlueButton
|
||||
puts command
|
||||
IO.popen(command)
|
||||
Process.wait
|
||||
elsif (height < MAX_VID_HEIGHT) and (width > MAX_VID_WIDTH)
|
||||
elsif (height < MAX_VID_HEIGHT) and (width > MAX_VID_WIDTH) or (landscape?(width, height)
|
||||
# Fit the video horizontally and adjust the height then pad the top and bottom to fit the 640x480 video.
|
||||
c_height = calc_height(anamorphic_factor)
|
||||
padding = MAX_VID_HEIGHT - c_height
|
||||
puts "w > mW and h < mH padding=#{padding}, c_height=#{c_height}"
|
||||
command = "ffmpeg -i #{flv_in} -aspect 4:3 -r 1000 -sameq -vf pad=#{MAX_VID_WIDTH}:#{MAX_VID_HEIGHT}:0:#{(padding/2).to_i}:FFFFFF -vcodec flashsv #{flv_out}"
|
||||
command = "ffmpeg -i #{flv_in} -aspect 4:3 -r 1000 -sameq -s #{MAX_VID_WIDTH}x#{c_height.to_i} -vf pad=#{MAX_VID_WIDTH}:#{MAX_VID_HEIGHT}:0:#{(padding/2).to_i}:FFFFFF -vcodec flashsv #{flv_out}"
|
||||
puts command
|
||||
IO.popen(command)
|
||||
Process.wait
|
||||
else
|
||||
if (portrait?(width, height))
|
||||
puts "portrait****####"
|
||||
else
|
||||
puts "landscape****####"
|
||||
end
|
||||
Process.wait
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user