Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,15 +38,17 @@ if uploaded_file is not None:
|
|
| 38 |
"-filter_complex", f"[0:v]setpts={video_speed}*PTS[v];[0:a]atempo={audio_speed}[a]",
|
| 39 |
"-map", "[v]", "-map", "[a]",
|
| 40 |
"-vcodec", "libx264", "-crf", "28", "-preset", "fast",
|
|
|
|
| 41 |
"-y", output_path
|
| 42 |
]
|
| 43 |
else:
|
| 44 |
-
# Lossless mode (copy
|
| 45 |
cmd = [
|
| 46 |
"ffmpeg", "-i", input_path,
|
| 47 |
"-filter_complex", f"[0:v]setpts={video_speed}*PTS[v];[0:a]atempo={audio_speed}[a]",
|
| 48 |
"-map", "[v]", "-map", "[a]",
|
| 49 |
-
"-c:v", "copy", "-c:a", "aac", "-b:a", "192k",
|
|
|
|
| 50 |
"-y", output_path
|
| 51 |
]
|
| 52 |
|
|
@@ -54,8 +56,10 @@ if uploaded_file is not None:
|
|
| 54 |
|
| 55 |
st.success("✅ Processing complete!")
|
| 56 |
|
|
|
|
| 57 |
st.video(output_path)
|
| 58 |
|
|
|
|
| 59 |
with open(output_path, "rb") as f:
|
| 60 |
st.download_button(
|
| 61 |
label="Download Processed Video",
|
|
|
|
| 38 |
"-filter_complex", f"[0:v]setpts={video_speed}*PTS[v];[0:a]atempo={audio_speed}[a]",
|
| 39 |
"-map", "[v]", "-map", "[a]",
|
| 40 |
"-vcodec", "libx264", "-crf", "28", "-preset", "fast",
|
| 41 |
+
"-movflags", "+faststart",
|
| 42 |
"-y", output_path
|
| 43 |
]
|
| 44 |
else:
|
| 45 |
+
# Lossless mode (copy video, re-encode only audio, make it browser-playable)
|
| 46 |
cmd = [
|
| 47 |
"ffmpeg", "-i", input_path,
|
| 48 |
"-filter_complex", f"[0:v]setpts={video_speed}*PTS[v];[0:a]atempo={audio_speed}[a]",
|
| 49 |
"-map", "[v]", "-map", "[a]",
|
| 50 |
+
"-c:v", "copy", "-c:a", "aac", "-b:a", "192k",
|
| 51 |
+
"-movflags", "+faststart", # ensures browser playback
|
| 52 |
"-y", output_path
|
| 53 |
]
|
| 54 |
|
|
|
|
| 56 |
|
| 57 |
st.success("✅ Processing complete!")
|
| 58 |
|
| 59 |
+
# Show processed video
|
| 60 |
st.video(output_path)
|
| 61 |
|
| 62 |
+
# Download button
|
| 63 |
with open(output_path, "rb") as f:
|
| 64 |
st.download_button(
|
| 65 |
label="Download Processed Video",
|