Compare commits
2 commits
400b880f63
...
9bd5d12874
| Author | SHA1 | Date | |
|---|---|---|---|
| 9bd5d12874 | |||
| 3c4119fc77 |
2 changed files with 84 additions and 15 deletions
49
render.py
49
render.py
|
|
@ -1147,3 +1147,52 @@ def unused_tags():
|
|||
for tag in sorted(unused_tags):
|
||||
count = unused_items.filter(data__tags__contains=tag).count()
|
||||
fd.write("%s (%d unused video clips)\n" % (tag, count))
|
||||
|
||||
def fragment_statistics():
|
||||
import itemlist.models
|
||||
import item.models
|
||||
stats = {}
|
||||
for l in itemlist.models.List.objects.filter(status='featured').order_by('name'):
|
||||
if l.name.split(' ')[0].isdigit():
|
||||
fragment_id = l.name.split(' ')[0]
|
||||
fragment = {
|
||||
'id': fragment_id,
|
||||
'name': l.name,
|
||||
'tags': [],
|
||||
'anti-tags': [],
|
||||
'description': l.description
|
||||
}
|
||||
for con in l.query['conditions']:
|
||||
if "conditions" in con:
|
||||
for sub in con["conditions"]:
|
||||
if sub['key'] == "tags" and sub['operator'] == '==':
|
||||
fragment['tags'].append(sub['value'].lower().strip())
|
||||
elif sub['key'] == "tags" and sub['operator'] == '!=':
|
||||
fragment['tags'].append(sub['value'].lower().strip())
|
||||
elif sub['key'] == 'type' and sub['value'] in ('source', ''):
|
||||
pass
|
||||
else:
|
||||
print(l.name, 'unknown sub condition', sub)
|
||||
elif con.get('key') == "tags" and con['operator'] == '==':
|
||||
fragment['tags'].append(con['value'].lower().strip())
|
||||
elif con.get('key') == "tags" and con['operator'] == '!=':
|
||||
fragment['anti-tags'].append(con['value'].lower().strip())
|
||||
|
||||
if fragment_id not in stats:
|
||||
stats[fragment_id] = {}
|
||||
for tag in fragment['tags']:
|
||||
stats[fragment_id][tag] = 0
|
||||
|
||||
for item in l.get_items(l.user).all():
|
||||
item_tags = [t.lower().strip() for t in item.get('tags')]
|
||||
if set(item_tags) & set(fragment['anti-tags']):
|
||||
continue
|
||||
for tag in set(fragment['tags']):
|
||||
if tag in item_tags:
|
||||
stats[fragment_id][tag] += 1
|
||||
with open("/srv/pandora/static/power/fragments.txt", "w") as fd:
|
||||
for fragment, data in stats.items():
|
||||
fd.write("%s\n" % fragment)
|
||||
for tag in sorted(data):
|
||||
fd.write(" %s: %s\n" % (tag, data[tag]))
|
||||
return stats
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ class KDEnliveProject:
|
|||
self, root,
|
||||
width="1920", height="1080",
|
||||
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._counters = defaultdict(int)
|
||||
|
|
@ -74,6 +75,7 @@ class KDEnliveProject:
|
|||
self._height = int(height)
|
||||
self._fps = int(frame_rate_num) / int(frame_rate_den)
|
||||
self.profile = 'atsc_1080p_24'
|
||||
self.scale_to_fill = scale_to_fill
|
||||
|
||||
self._tree = self.get_element("mlt", attrib={
|
||||
"LC_NUMERIC": "C",
|
||||
|
|
@ -627,20 +629,38 @@ class KDEnliveProject:
|
|||
idx = self._tree.index(track) - 1
|
||||
self._tree.insert(idx, chain)
|
||||
filters_ = []
|
||||
if track_id == 'V':
|
||||
filters_.append({
|
||||
if track_id[0] == 'V':
|
||||
if self.scale_to_fill:
|
||||
width = self._width
|
||||
height = self._height
|
||||
x = 0
|
||||
y = 0
|
||||
codec_width = chain.xpath('property[@name="meta.media.0.codec.width"]')
|
||||
if codec_width:
|
||||
codec_height = chain.xpath('property[@name="meta.media.0.codec.height"]')
|
||||
clip_width = int(codec_width[0].text)
|
||||
clip_height = int(codec_height[0].text)
|
||||
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", "00:00:00.000=0 0 %s %s 1.000000" % (self._width, self.height)],
|
||||
["rect", rect],
|
||||
["rotation", "00:00:00.000=0"],
|
||||
["compositing", "0"],
|
||||
["distort", "0"],
|
||||
["kdenlive:collapsed", "0"],
|
||||
["disable", "0"],
|
||||
])
|
||||
})
|
||||
)
|
||||
|
||||
for ft in filters.items():
|
||||
filters_ += self.get_filter(*ft)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue