text
stringlengths
0
284
"-pass", "2",
output_location
]
print("Running first pass ffmpeg encoding")
run_cmd([ffmpeg_path] + first_pass_args)
print("Running second pass ffmpeg encoding. This could take awhile...")
run_cmd([ffmpeg_path] + second_pass_args)
else:
print("Running ffmpeg encoding. This could take awhile...")
run_cmd([ffmpeg_path] + args + [output_location])
if(create_segments):
print("Segmenting video")
run_cmd([ffmpeg_path] + [
"-i", output_location,
"-f", "segment",
"-segment_time", segment_duration,
"-vcodec", "copy",
"-acodec", "copy",
f"{output_dir}.%d.{suffix}"
])
def set_weights(match_obj, wave_progress):
weight_0 = 0
weight_1 = 0
if match_obj.group(1) is not None:
weight_0 = float(match_obj.group(1))
if match_obj.group(2) is not None:
weight_1 = float(match_obj.group(2))
max_weight = max(weight_0, weight_1)
min_weight = min(weight_0, weight_1)
weight_range = max_weight - min_weight
weight = min_weight + weight_range * wave_progress
return str(weight)
class Script(scripts.Script):
def title(self):
return "Loopback Wave V1.4.1"
def show(self, is_img2img):
return is_img2img
def ui(self, is_img2img):
frames = gr.Slider(minimum=1, maximum=2048, step=1, label='Frames', value=100)
frames_per_wave = gr.Slider(minimum=0, maximum=120, step=1, label='Frames Per Wave', value=20)
denoising_strength_change_amplitude = gr.Slider(minimum=0, maximum=1, step=0.01, label='Max additional denoise', value=0.6)
denoising_strength_change_offset = gr.Number(minimum=0, maximum=180, step=1, label='Wave offset (ignore this if you don\'t know what it means)', value=0)
initial_image_number = gr.Number(minimum=0, label='Initial generated image number', value=0)
save_prompts = gr.Checkbox(label='Save prompts as text file', value=True)
prompts = gr.Textbox(label="Prompt Changes", lines=5, value="")
save_video = gr.Checkbox(label='Save results as video', value=True)
output_dir = gr.Textbox(label="Video Name", lines=1, value="")
video_fps = gr.Slider(minimum=1, maximum=120, step=1, label='Frames per second', value=10)
video_quality = gr.Slider(minimum=0, maximum=60, step=1, label='Video Quality (crf)', value=40)
video_encoding = gr.Dropdown(label='Video encoding', value="VP9 (webm)", choices=["VP9 (webm)", "VP8 (webm)", "H.265 (mp4)", "H.264 (mp4)"])
ffmpeg_path = gr.Textbox(label="ffmpeg binary. Only set this if it fails otherwise.", lines=1, value="")
segment_video = gr.Checkbox(label='Cut video in to segments', value=True)
video_segment_duration = gr.Slider(minimum=10, maximum=60, step=1, label='Video Segment Duration (seconds)', value=20)
return [frames, denoising_strength_change_amplitude, frames_per_wave, denoising_strength_change_offset,initial_image_number, prompts, save_prompts, save_video, output_dir, video_fps, video_quality, video_encoding, ffmpeg_path, segment_video, video_segment_duration]
def run(self, p, frames, denoising_strength_change_amplitude, frames_per_wave, denoising_strength_change_offset, initial_image_number, prompts: str,save_prompts, save_video, output_dir, video_fps, video_quality, video_encoding, ffmpeg_path, segment_video, video_segment_duration):
processing.fix_seed(p)
batch_count = p.n_iter
p.extra_generation_params = {
"Max Additional Denoise": denoising_strength_change_amplitude,
"Frames per wave": frames_per_wave,
"Wave Offset": denoising_strength_change_offset,
}
# We save them ourselves for the sake of ffmpeg
p.do_not_save_samples = True
changes_dict = {}
p.batch_size = 1
p.n_iter = 1
output_images, info = None, None
initial_seed = None
initial_info = None
grids = []
all_images = []
original_init_image = p.init_images
state.job_count = frames * batch_count
initial_color_corrections = [processing.setup_color_correction(p.init_images[0])]
initial_denoising_strength = p.denoising_strength