annotation segment mode
This commit is contained in:
parent
8d0bb0a211
commit
400b880f63
1 changed files with 7 additions and 5 deletions
12
generate.py
12
generate.py
|
|
@ -995,7 +995,7 @@ def reshoot_item_segments(item, character, keep=False):
|
||||||
source = item.files.all()[0].data.path
|
source = item.files.all()[0].data.path
|
||||||
info = ox.avinfo(source)
|
info = ox.avinfo(source)
|
||||||
duration = info["duration"]
|
duration = info["duration"]
|
||||||
if duration < max_duration:
|
if duration < max_duration and character != "annotation":
|
||||||
segments = [duration]
|
segments = [duration]
|
||||||
else:
|
else:
|
||||||
segments = get_item_segments(item, max_duration=max_duration)
|
segments = get_item_segments(item, max_duration=max_duration)
|
||||||
|
|
@ -1024,15 +1024,15 @@ def reshoot_item_segments(item, character, keep=False):
|
||||||
if character == "annotation":
|
if character == "annotation":
|
||||||
a = item.annotations.filter(
|
a = item.annotations.filter(
|
||||||
layer='prompts', start__gte=position, end__gt=position
|
layer='prompts', start__gte=position, end__gt=position
|
||||||
).order_by('start').first()
|
).exclude(start__gte=segment).order_by('start').first()
|
||||||
if a:
|
if a:
|
||||||
segment_character = a.value
|
segment_character = a.value
|
||||||
|
print('use character from annotation', a, segment_character, 'for %s-%s' % (position, segment))
|
||||||
else:
|
else:
|
||||||
segment_character = None
|
segment_character = None
|
||||||
|
print('use no character for %s-%s' % (position, segment))
|
||||||
else:
|
else:
|
||||||
segment_character = character
|
segment_character = character
|
||||||
if position:
|
|
||||||
segment_character = segment_first_frame_url
|
|
||||||
if segment_character:
|
if segment_character:
|
||||||
segment_first_frame = replace_character(
|
segment_first_frame = replace_character(
|
||||||
item, segment_character, position, seed=seed
|
item, segment_character, position, seed=seed
|
||||||
|
|
@ -1048,7 +1048,8 @@ def reshoot_item_segments(item, character, keep=False):
|
||||||
frames = int(segment_duration * 24)
|
frames = int(segment_duration * 24)
|
||||||
trim_video(output_ai, trimmed, frames, stype == "c")
|
trim_video(output_ai, trimmed, frames, stype == "c")
|
||||||
processed.append(trimmed)
|
processed.append(trimmed)
|
||||||
first_frames.append(segment_first_frame)
|
if segment_character:
|
||||||
|
first_frames.append(segment_first_frame)
|
||||||
n += 1
|
n += 1
|
||||||
position = segment
|
position = segment
|
||||||
joined_output = "%s/joined.mp4" % (prefix)
|
joined_output = "%s/joined.mp4" % (prefix)
|
||||||
|
|
@ -1318,6 +1319,7 @@ def fragment_video(filename, segmentdir, segments):
|
||||||
if last is None:
|
if last is None:
|
||||||
os.unlink(output_path)
|
os.unlink(output_path)
|
||||||
else:
|
else:
|
||||||
|
print(frame_count, output_path)
|
||||||
cv2.imwrite(output_path.replace(".mp4", "_last.jpg"), last)
|
cv2.imwrite(output_path.replace(".mp4", "_last.jpg"), last)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue