File size: 1,737 Bytes
50742c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import streamlit as st
import ffmpeg
import os
from tempfile import NamedTemporaryFile

def interpolate_video(input_file, fps):
    output_path = "framer_interpolated.mp4"

    # Интерполяция кадров с использованием фильтра minterpolate, сохраняя звук
    (
        ffmpeg
        .input(input_file)
        .filter('minterpolate', fps=fps)
        .output(output_path, acodec='copy')
        .run(overwrite_output=True)
    )

    return output_path

# Заголовок приложения
st.title("Framer! - Frame interpolation with FFmpeg")
st.write("Upload a video and adjust the slider to set the target frame rate (FPS) for interpolation.")

# Загрузка видеофайла
uploaded_file = st.file_uploader("Upload Video", type=["mp4", "avi", "mov", "mkv"])

# Слайдер для выбора FPS
fps = st.slider("Frame Rate (FPS)", min_value=24, max_value=60, value=60, step=1)

if uploaded_file is not None:
    # Сохранение загруженного видео во временный файл
    with NamedTemporaryFile(delete=False, suffix=".mp4") as temp_file:
        temp_file.write(uploaded_file.read())
        temp_file_path = temp_file.name

    # Кнопка для запуска интерполяции
    if st.button("Interpolate Video"):
        st.write("Processing your video...")
        output_path = interpolate_video(temp_file_path, fps)

        # Отображение результата
        st.success("Video interpolation complete!")
        st.video(output_path)

        # Удаление временного файла
        os.remove(temp_file_path)
else:
    st.info("Please upload a video to get started.")