Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -39,18 +39,14 @@ def process_videos(zip_file):
|
|
39 |
# ビデオの読み込み
|
40 |
cap = cv2.VideoCapture(input_path)
|
41 |
|
42 |
-
#
|
43 |
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
44 |
-
|
45 |
|
46 |
# 出力ビデオライターの設定
|
47 |
-
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
48 |
out_normal = cv2.VideoWriter(output_path, fourcc, fps, (1080, 1920))
|
49 |
out_upscaled = cv2.VideoWriter(output_upscaled_path, fourcc, fps, (2160, 3840))
|
50 |
|
51 |
-
# プログレスバー用
|
52 |
-
pbar = tqdm(total=total_frames, desc=f"Processing {file}")
|
53 |
-
|
54 |
while cap.isOpened():
|
55 |
ret, frame = cap.read()
|
56 |
if not ret:
|
@@ -61,14 +57,10 @@ def process_videos(zip_file):
|
|
61 |
out_normal.write(resized_frame)
|
62 |
|
63 |
# 高解像度アップスケール (2160x3840)
|
64 |
-
# INTER_CUBIC を使用してより良い品質を得る
|
65 |
upscaled_frame = cv2.resize(resized_frame, (2160, 3840),
|
66 |
interpolation=cv2.INTER_CUBIC)
|
67 |
out_upscaled.write(upscaled_frame)
|
68 |
-
|
69 |
-
pbar.update(1)
|
70 |
|
71 |
-
pbar.close()
|
72 |
cap.release()
|
73 |
out_normal.release()
|
74 |
out_upscaled.release()
|
@@ -102,7 +94,7 @@ def process_videos(zip_file):
|
|
102 |
|
103 |
# Gradioインターフェースの作成
|
104 |
with gr.Blocks() as app:
|
105 |
-
gr.Markdown("##
|
106 |
gr.Markdown("1. フォルダ内の動画ファイルをZIPにまとめてアップロードしてください")
|
107 |
gr.Markdown("2. 全ての動画が以下の2つの解像度で出力されます:")
|
108 |
gr.Markdown(" - 標準解像度: 1080x1920")
|
|
|
39 |
# ビデオの読み込み
|
40 |
cap = cv2.VideoCapture(input_path)
|
41 |
|
42 |
+
# 入力ビデオのプロパティを取得
|
43 |
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
44 |
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
45 |
|
46 |
# 出力ビデオライターの設定
|
|
|
47 |
out_normal = cv2.VideoWriter(output_path, fourcc, fps, (1080, 1920))
|
48 |
out_upscaled = cv2.VideoWriter(output_upscaled_path, fourcc, fps, (2160, 3840))
|
49 |
|
|
|
|
|
|
|
50 |
while cap.isOpened():
|
51 |
ret, frame = cap.read()
|
52 |
if not ret:
|
|
|
57 |
out_normal.write(resized_frame)
|
58 |
|
59 |
# 高解像度アップスケール (2160x3840)
|
|
|
60 |
upscaled_frame = cv2.resize(resized_frame, (2160, 3840),
|
61 |
interpolation=cv2.INTER_CUBIC)
|
62 |
out_upscaled.write(upscaled_frame)
|
|
|
|
|
63 |
|
|
|
64 |
cap.release()
|
65 |
out_normal.release()
|
66 |
out_upscaled.release()
|
|
|
94 |
|
95 |
# Gradioインターフェースの作成
|
96 |
with gr.Blocks() as app:
|
97 |
+
gr.Markdown("## 動画リサイズツール")
|
98 |
gr.Markdown("1. フォルダ内の動画ファイルをZIPにまとめてアップロードしてください")
|
99 |
gr.Markdown("2. 全ての動画が以下の2つの解像度で出力されます:")
|
100 |
gr.Markdown(" - 標準解像度: 1080x1920")
|