Update app.py
Browse files
app.py
CHANGED
@@ -175,7 +175,9 @@ def infer_video_depth(
|
|
175 |
concat_file_path = os.path.join(output_dir, 'concat_list.txt')
|
176 |
with open(concat_file_path, 'w') as f:
|
177 |
for _ in range(loop_factor):
|
178 |
-
|
|
|
|
|
179 |
|
180 |
# Verwende ffmpeg, um das Video zu wiederholen ohne Neucodierung
|
181 |
cmd = [
|
@@ -199,12 +201,10 @@ def infer_video_depth(
|
|
199 |
if stitch and stitched_video_path:
|
200 |
# Speichern wir den Originalnamen und absoluten Pfad
|
201 |
original_path = stitched_video_path
|
|
|
202 |
|
203 |
print(f"Looping video {original_path} with factor {loop_factor}")
|
204 |
|
205 |
-
# Pfad für das Ausgangsverzeichnis sicherstellen
|
206 |
-
output_folder = os.path.dirname(original_path)
|
207 |
-
|
208 |
# Überprüfen wir, ob das Input-Video einen Audio-Stream hat
|
209 |
has_audio = False
|
210 |
check_audio_cmd = [
|
@@ -220,17 +220,19 @@ def infer_video_depth(
|
|
220 |
has_audio = True
|
221 |
print("Audio stream detected in input video")
|
222 |
|
223 |
-
# Temporärer Pfad
|
224 |
-
temp_looped_path = os.path.join(
|
225 |
|
226 |
try:
|
227 |
# Erstelle eine temporäre Textdatei für die stitched Videos
|
228 |
-
concat_stitched_file_path = os.path.join(
|
229 |
with open(concat_stitched_file_path, 'w') as f:
|
230 |
for _ in range(loop_factor):
|
231 |
-
|
|
|
232 |
|
233 |
print(f"Creating temporary file at: {temp_looped_path}")
|
|
|
234 |
|
235 |
# Verwende ffmpeg, um das Video zu loopen
|
236 |
concat_cmd = [
|
@@ -250,14 +252,14 @@ def infer_video_depth(
|
|
250 |
# Überprüfe, ob die temporäre Datei erzeugt wurde
|
251 |
if not os.path.exists(temp_looped_path):
|
252 |
print(f"ERROR: Failed to create temporary file {temp_looped_path}")
|
253 |
-
print(f"Current directory contents: {os.listdir(
|
254 |
# Fallback
|
255 |
return [depth_vis_path, stitched_video_path]
|
256 |
|
257 |
# Wenn Audio vorhanden ist, müssen wir es separat behandeln
|
258 |
if has_audio:
|
259 |
# Extrahiere den Audio-Track aus dem originalen Input-Video
|
260 |
-
audio_path = os.path.join(
|
261 |
extract_audio_cmd = [
|
262 |
"ffmpeg",
|
263 |
"-y",
|
@@ -273,13 +275,15 @@ def infer_video_depth(
|
|
273 |
has_audio = False
|
274 |
else:
|
275 |
# Erstelle eine Textdatei für das Audio-Looping
|
276 |
-
concat_audio_file_path = os.path.join(
|
277 |
with open(concat_audio_file_path, 'w') as f:
|
278 |
for _ in range(loop_factor):
|
279 |
-
|
|
|
|
|
280 |
|
281 |
# Erstelle den geloopten Audio-Track
|
282 |
-
looped_audio_path = os.path.join(
|
283 |
audio_loop_cmd = [
|
284 |
"ffmpeg",
|
285 |
"-y",
|
@@ -345,6 +349,8 @@ def infer_video_depth(
|
|
345 |
|
346 |
except Exception as e:
|
347 |
print(f"Error during looping process: {str(e)}")
|
|
|
|
|
348 |
# Im Fehlerfall die ursprünglichen Dateien behalten
|
349 |
return [depth_vis_path, stitched_video_path]
|
350 |
|
|
|
175 |
concat_file_path = os.path.join(output_dir, 'concat_list.txt')
|
176 |
with open(concat_file_path, 'w') as f:
|
177 |
for _ in range(loop_factor):
|
178 |
+
# Absoluten Pfad verwenden
|
179 |
+
abs_path = os.path.abspath(depth_vis_path)
|
180 |
+
f.write(f"file '{abs_path}'\n")
|
181 |
|
182 |
# Verwende ffmpeg, um das Video zu wiederholen ohne Neucodierung
|
183 |
cmd = [
|
|
|
201 |
if stitch and stitched_video_path:
|
202 |
# Speichern wir den Originalnamen und absoluten Pfad
|
203 |
original_path = stitched_video_path
|
204 |
+
abs_original_path = os.path.abspath(original_path)
|
205 |
|
206 |
print(f"Looping video {original_path} with factor {loop_factor}")
|
207 |
|
|
|
|
|
|
|
208 |
# Überprüfen wir, ob das Input-Video einen Audio-Stream hat
|
209 |
has_audio = False
|
210 |
check_audio_cmd = [
|
|
|
220 |
has_audio = True
|
221 |
print("Audio stream detected in input video")
|
222 |
|
223 |
+
# Temporärer Pfad im Output-Verzeichnis
|
224 |
+
temp_looped_path = os.path.join(output_dir, 'temp_rgbd_looped.mp4')
|
225 |
|
226 |
try:
|
227 |
# Erstelle eine temporäre Textdatei für die stitched Videos
|
228 |
+
concat_stitched_file_path = os.path.join(output_dir, 'concat_stitched_list.txt')
|
229 |
with open(concat_stitched_file_path, 'w') as f:
|
230 |
for _ in range(loop_factor):
|
231 |
+
# Absoluten Pfad verwenden
|
232 |
+
f.write(f"file '{abs_original_path}'\n")
|
233 |
|
234 |
print(f"Creating temporary file at: {temp_looped_path}")
|
235 |
+
print(f"Using absolute path for original: {abs_original_path}")
|
236 |
|
237 |
# Verwende ffmpeg, um das Video zu loopen
|
238 |
concat_cmd = [
|
|
|
252 |
# Überprüfe, ob die temporäre Datei erzeugt wurde
|
253 |
if not os.path.exists(temp_looped_path):
|
254 |
print(f"ERROR: Failed to create temporary file {temp_looped_path}")
|
255 |
+
print(f"Current directory contents: {os.listdir(output_dir)}")
|
256 |
# Fallback
|
257 |
return [depth_vis_path, stitched_video_path]
|
258 |
|
259 |
# Wenn Audio vorhanden ist, müssen wir es separat behandeln
|
260 |
if has_audio:
|
261 |
# Extrahiere den Audio-Track aus dem originalen Input-Video
|
262 |
+
audio_path = os.path.join(output_dir, 'extracted_audio.aac')
|
263 |
extract_audio_cmd = [
|
264 |
"ffmpeg",
|
265 |
"-y",
|
|
|
275 |
has_audio = False
|
276 |
else:
|
277 |
# Erstelle eine Textdatei für das Audio-Looping
|
278 |
+
concat_audio_file_path = os.path.join(output_dir, 'concat_audio_list.txt')
|
279 |
with open(concat_audio_file_path, 'w') as f:
|
280 |
for _ in range(loop_factor):
|
281 |
+
# Absoluten Pfad verwenden
|
282 |
+
abs_audio_path = os.path.abspath(audio_path)
|
283 |
+
f.write(f"file '{abs_audio_path}'\n")
|
284 |
|
285 |
# Erstelle den geloopten Audio-Track
|
286 |
+
looped_audio_path = os.path.join(output_dir, 'looped_audio.aac')
|
287 |
audio_loop_cmd = [
|
288 |
"ffmpeg",
|
289 |
"-y",
|
|
|
349 |
|
350 |
except Exception as e:
|
351 |
print(f"Error during looping process: {str(e)}")
|
352 |
+
import traceback
|
353 |
+
traceback.print_exc()
|
354 |
# Im Fehlerfall die ursprünglichen Dateien behalten
|
355 |
return [depth_vis_path, stitched_video_path]
|
356 |
|