import gradio as gr | |
import ffmpeg # cool | |
def interpolate_video(video, fps): | |
input_path = video.name | |
output_path = "framer_interpolated.mp4" | |
# Интерполяция кадров с использованием фильтра minterpolate, сохраняя звук | |
( | |
ffmpeg | |
.input(input_path) | |
.filter('minterpolate', fps=fps) | |
.output(output_path, acodec='copy') | |
.run(overwrite_output=True) | |
) | |
return output_path | |
iface = gr.Interface( | |
fn=interpolate_video, | |
inputs=[ | |
gr.File(label="Upload Video"), | |
gr.Slider(minimum=24, maximum=60, step=1, value=60, label="Frame Rate (FPS)") | |
], | |
outputs=gr.Video(label="Interpolated Video"), | |
title="Framer! - frame interpolation with FFmpeg!", | |
description="Upload a video and adjust the slider to set the target frame rate (FPS) for interpolation." | |
) | |
if __name__ == "__main__": | |
iface.launch() |