fix scale to fill
This commit is contained in:
parent
400b880f63
commit
3c4119fc77
1 changed files with 35 additions and 15 deletions
|
|
@ -65,7 +65,8 @@ class KDEnliveProject:
|
||||||
self, root,
|
self, root,
|
||||||
width="1920", height="1080",
|
width="1920", height="1080",
|
||||||
display_aspect_num="16", display_aspect_den="9",
|
display_aspect_num="16", display_aspect_den="9",
|
||||||
frame_rate_num="24", frame_rate_den="1"
|
frame_rate_num="24", frame_rate_den="1",
|
||||||
|
scale_to_fill=True
|
||||||
):
|
):
|
||||||
self._duration = defaultdict(int)
|
self._duration = defaultdict(int)
|
||||||
self._counters = defaultdict(int)
|
self._counters = defaultdict(int)
|
||||||
|
|
@ -74,6 +75,7 @@ class KDEnliveProject:
|
||||||
self._height = int(height)
|
self._height = int(height)
|
||||||
self._fps = int(frame_rate_num) / int(frame_rate_den)
|
self._fps = int(frame_rate_num) / int(frame_rate_den)
|
||||||
self.profile = 'atsc_1080p_24'
|
self.profile = 'atsc_1080p_24'
|
||||||
|
self.scale_to_fill = scale_to_fill
|
||||||
|
|
||||||
self._tree = self.get_element("mlt", attrib={
|
self._tree = self.get_element("mlt", attrib={
|
||||||
"LC_NUMERIC": "C",
|
"LC_NUMERIC": "C",
|
||||||
|
|
@ -627,20 +629,38 @@ class KDEnliveProject:
|
||||||
idx = self._tree.index(track) - 1
|
idx = self._tree.index(track) - 1
|
||||||
self._tree.insert(idx, chain)
|
self._tree.insert(idx, chain)
|
||||||
filters_ = []
|
filters_ = []
|
||||||
if track_id == 'V':
|
if track_id[0] == 'V':
|
||||||
filters_.append({
|
if self.scale_to_fill:
|
||||||
self.get_element("filter", [
|
width = self._width
|
||||||
["mlt_service", "qtblend"],
|
height = self._height
|
||||||
["kdenlive_id", "qtblend"],
|
x = 0
|
||||||
["rotate_center", "1"],
|
y = 0
|
||||||
["rect", "00:00:00.000=0 0 %s %s 1.000000" % (self._width, self.height)],
|
codec_width = chain.xpath('property[@name="meta.media.0.codec.width"]')
|
||||||
["rotation", "00:00:00.000=0"],
|
if codec_width:
|
||||||
["compositing", "0"],
|
codec_height = chain.xpath('property[@name="meta.media.0.codec.height"]')
|
||||||
["distort", "0"],
|
clip_width = int(codec_width[0].text)
|
||||||
["kdenlive:collapsed", "0"],
|
clip_height = int(codec_height[0].text)
|
||||||
["disable", "0"],
|
if clip_width == width and clip_height > height:
|
||||||
])
|
y = int((height - clip_height) / 2)
|
||||||
})
|
elif clip_width/clip_height < width/height:
|
||||||
|
target_height = int(clip_height/clip_width * width)
|
||||||
|
y = int((height - target_height) / 2)
|
||||||
|
height = target_height
|
||||||
|
print("scale to fill %s %sx%s" % (path, width, height))
|
||||||
|
rect = "00:00:00.000=%s %s %s %s 1.000000" % (x, y, width, height)
|
||||||
|
filters_.append(
|
||||||
|
self.get_element("filter", [
|
||||||
|
["mlt_service", "qtblend"],
|
||||||
|
["kdenlive_id", "qtblend"],
|
||||||
|
["rotate_center", "1"],
|
||||||
|
["rect", rect],
|
||||||
|
["rotation", "00:00:00.000=0"],
|
||||||
|
["compositing", "0"],
|
||||||
|
["distort", "0"],
|
||||||
|
["kdenlive:collapsed", "0"],
|
||||||
|
["disable", "0"],
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for ft in filters.items():
|
for ft in filters.items():
|
||||||
filters_ += self.get_filter(*ft)
|
filters_ += self.get_filter(*ft)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue