Spaces:
Running
on
Zero
Running
on
Zero
alex
commited on
Commit
·
0675e33
1
Parent(s):
b3c4c85
no audio, no problem
Browse files
app.py
CHANGED
|
@@ -104,8 +104,9 @@ def extract_audio_from_video_ffmpeg(video_path, output_wav_path, sample_rate=Non
|
|
| 104 |
|
| 105 |
try:
|
| 106 |
subprocess.run(cmd, check=True, capture_output=True, text=True)
|
|
|
|
| 107 |
except subprocess.CalledProcessError as e:
|
| 108 |
-
|
| 109 |
|
| 110 |
|
| 111 |
def combine_video_and_audio_ffmpeg(video_path, audio_path, output_video_path):
|
|
@@ -318,7 +319,11 @@ def animate_scene(input_video, edited_frame, rc_str, session_id = None, progress
|
|
| 318 |
|
| 319 |
input_audio_path = os.path.join(output_dir, 'input_audio.wav')
|
| 320 |
|
| 321 |
-
extract_audio_from_video_ffmpeg(input_video, input_audio_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
output_video_path = _animate(input_video, edited_frame, rc_bool, session_id, progress)
|
| 324 |
|
|
@@ -336,8 +341,10 @@ def animate_scene(input_video, edited_frame, rc_str, session_id = None, progress
|
|
| 336 |
bg_video = os.path.join(preprocess_dir, 'src_pose.mp4')
|
| 337 |
face_video = os.path.join(preprocess_dir, 'src_pose.mp4')
|
| 338 |
|
| 339 |
-
|
| 340 |
-
|
|
|
|
|
|
|
| 341 |
return final_video_path, pose_video, bg_video, mask_video, face_video
|
| 342 |
|
| 343 |
css = """
|
|
|
|
| 104 |
|
| 105 |
try:
|
| 106 |
subprocess.run(cmd, check=True, capture_output=True, text=True)
|
| 107 |
+
return True
|
| 108 |
except subprocess.CalledProcessError as e:
|
| 109 |
+
return False
|
| 110 |
|
| 111 |
|
| 112 |
def combine_video_and_audio_ffmpeg(video_path, audio_path, output_video_path):
|
|
|
|
| 319 |
|
| 320 |
input_audio_path = os.path.join(output_dir, 'input_audio.wav')
|
| 321 |
|
| 322 |
+
audio_extracted = extract_audio_from_video_ffmpeg(input_video, input_audio_path)
|
| 323 |
+
|
| 324 |
+
edited_frame_png = os.path.join(output_dir, 'edited_frame.png')
|
| 325 |
+
edited_frame_img = Image.open(edited_frame)
|
| 326 |
+
edited_frame_img.save(edited_frame_png)
|
| 327 |
|
| 328 |
output_video_path = _animate(input_video, edited_frame, rc_bool, session_id, progress)
|
| 329 |
|
|
|
|
| 341 |
bg_video = os.path.join(preprocess_dir, 'src_pose.mp4')
|
| 342 |
face_video = os.path.join(preprocess_dir, 'src_pose.mp4')
|
| 343 |
|
| 344 |
+
if audio_extracted:
|
| 345 |
+
combine_video_and_audio_ffmpeg(output_video_path, input_audio_path, final_video_path)
|
| 346 |
+
else:
|
| 347 |
+
final_video_path = output_video_path
|
| 348 |
return final_video_path, pose_video, bg_video, mask_video, face_video
|
| 349 |
|
| 350 |
css = """
|