Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -865,7 +865,7 @@ def _extract_audio_from_video(video_path: str) -> str | None:
|
|
| 865 |
# Extract audio
|
| 866 |
subprocess.run(
|
| 867 |
["ffmpeg", "-y", "-v", "error", "-i", video_path,
|
| 868 |
-
"-vn", "-ac", "
|
| 869 |
check=True,
|
| 870 |
)
|
| 871 |
return out_path
|
|
@@ -884,6 +884,7 @@ def generate_video(
|
|
| 884 |
conditioning_strength: float,
|
| 885 |
video_preprocess: str,
|
| 886 |
enhance_prompt: bool,
|
|
|
|
| 887 |
seed: int,
|
| 888 |
randomize_seed: bool,
|
| 889 |
height: int,
|
|
@@ -945,8 +946,8 @@ def generate_video(
|
|
| 945 |
# Raw mode — pass video as-is
|
| 946 |
video_conditioning = [(video_path, 1.0)]
|
| 947 |
|
| 948 |
-
# If no audio was provided,
|
| 949 |
-
if input_audio is None:
|
| 950 |
extracted_audio = _extract_audio_from_video(video_path)
|
| 951 |
if extracted_audio is not None:
|
| 952 |
input_audio = extracted_audio
|
|
@@ -1027,11 +1028,6 @@ with gr.Blocks(title="LTX-2.3 Unified: V2V + I2V + A2V") as demo:
|
|
| 1027 |
label="🔊 Input Audio (A2V — lipsync / BGM)",
|
| 1028 |
type="filepath",
|
| 1029 |
)
|
| 1030 |
-
gr.Markdown(
|
| 1031 |
-
"*When a video is uploaded: its first frame auto-becomes the image input "
|
| 1032 |
-
"(if none provided), and its audio track auto-becomes the audio input "
|
| 1033 |
-
"(if none provided).*"
|
| 1034 |
-
)
|
| 1035 |
|
| 1036 |
prompt = gr.Textbox(
|
| 1037 |
label="Prompt",
|
|
@@ -1055,6 +1051,11 @@ with gr.Blocks(title="LTX-2.3 Unified: V2V + I2V + A2V") as demo:
|
|
| 1055 |
with gr.Row():
|
| 1056 |
enhance_prompt = gr.Checkbox(label="Enhance Prompt", value=True)
|
| 1057 |
high_res = gr.Checkbox(label="High Resolution", value=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1058 |
|
| 1059 |
generate_btn = gr.Button("Generate Video", variant="primary", size="lg")
|
| 1060 |
|
|
@@ -1091,7 +1092,7 @@ with gr.Blocks(title="LTX-2.3 Unified: V2V + I2V + A2V") as demo:
|
|
| 1091 |
inputs=[
|
| 1092 |
input_image, input_video, input_audio, prompt, duration,
|
| 1093 |
conditioning_strength, video_preprocess, enhance_prompt,
|
| 1094 |
-
seed, randomize_seed, height, width,
|
| 1095 |
],
|
| 1096 |
outputs=[output_video, seed],
|
| 1097 |
)
|
|
|
|
| 865 |
# Extract audio
|
| 866 |
subprocess.run(
|
| 867 |
["ffmpeg", "-y", "-v", "error", "-i", video_path,
|
| 868 |
+
"-vn", "-ac", "2", "-ar", "48000", "-c:a", "pcm_s16le", out_path],
|
| 869 |
check=True,
|
| 870 |
)
|
| 871 |
return out_path
|
|
|
|
| 884 |
conditioning_strength: float,
|
| 885 |
video_preprocess: str,
|
| 886 |
enhance_prompt: bool,
|
| 887 |
+
use_video_audio: bool,
|
| 888 |
seed: int,
|
| 889 |
randomize_seed: bool,
|
| 890 |
height: int,
|
|
|
|
| 946 |
# Raw mode — pass video as-is
|
| 947 |
video_conditioning = [(video_path, 1.0)]
|
| 948 |
|
| 949 |
+
# If no audio was provided, optionally extract audio from the video
|
| 950 |
+
if input_audio is None and use_video_audio:
|
| 951 |
extracted_audio = _extract_audio_from_video(video_path)
|
| 952 |
if extracted_audio is not None:
|
| 953 |
input_audio = extracted_audio
|
|
|
|
| 1028 |
label="🔊 Input Audio (A2V — lipsync / BGM)",
|
| 1029 |
type="filepath",
|
| 1030 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1031 |
|
| 1032 |
prompt = gr.Textbox(
|
| 1033 |
label="Prompt",
|
|
|
|
| 1051 |
with gr.Row():
|
| 1052 |
enhance_prompt = gr.Checkbox(label="Enhance Prompt", value=True)
|
| 1053 |
high_res = gr.Checkbox(label="High Resolution", value=True)
|
| 1054 |
+
use_video_audio = gr.Checkbox(
|
| 1055 |
+
label="Use Audio from Video",
|
| 1056 |
+
value=True,
|
| 1057 |
+
info="Extract and use the audio track from the reference video",
|
| 1058 |
+
)
|
| 1059 |
|
| 1060 |
generate_btn = gr.Button("Generate Video", variant="primary", size="lg")
|
| 1061 |
|
|
|
|
| 1092 |
inputs=[
|
| 1093 |
input_image, input_video, input_audio, prompt, duration,
|
| 1094 |
conditioning_strength, video_preprocess, enhance_prompt,
|
| 1095 |
+
use_video_audio, seed, randomize_seed, height, width,
|
| 1096 |
],
|
| 1097 |
outputs=[output_video, seed],
|
| 1098 |
)
|