files
Browse files- app.py +2 -5
- video_editing_ffmpeg.py +6 -1
app.py
CHANGED
|
@@ -105,8 +105,5 @@ with gr.Blocks() as demo:
|
|
| 105 |
outputs=[video_output, generation_status,generated_story]
|
| 106 |
)
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
if __name__ == "__main__":
|
| 111 |
-
# Launch the app (Pyodide-compatible launch)
|
| 112 |
-
demo.launch()
|
|
|
|
| 105 |
outputs=[video_output, generation_status,generated_story]
|
| 106 |
)
|
| 107 |
|
| 108 |
+
# Launch the app (Pyodide-compatible launch)
|
| 109 |
+
demo.launch(share=true)
|
|
|
|
|
|
|
|
|
video_editing_ffmpeg.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import ffmpeg
|
| 2 |
import random
|
| 3 |
import string
|
|
|
|
| 4 |
# Define target resolution
|
| 5 |
target_width = 1080
|
| 6 |
target_height = 1920
|
|
@@ -13,12 +14,16 @@ def concatenate_videos(files_timestamps):
|
|
| 13 |
file_path = file_info["path"]
|
| 14 |
start_time = file_info["start"]
|
| 15 |
end_time = file_info["end"]
|
| 16 |
-
|
| 17 |
try:
|
| 18 |
if end_time == "":
|
| 19 |
# Create input stream from start_time to end of video
|
| 20 |
stream = ffmpeg.input(file_path, ss=start_time)
|
| 21 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# Create input stream with trimming
|
| 23 |
stream = ffmpeg.input(file_path, ss=start_time, t=end_time - start_time)
|
| 24 |
video = stream.video
|
|
|
|
| 1 |
import ffmpeg
|
| 2 |
import random
|
| 3 |
import string
|
| 4 |
+
from datetime import datetime
|
| 5 |
# Define target resolution
|
| 6 |
target_width = 1080
|
| 7 |
target_height = 1920
|
|
|
|
| 14 |
file_path = file_info["path"]
|
| 15 |
start_time = file_info["start"]
|
| 16 |
end_time = file_info["end"]
|
| 17 |
+
|
| 18 |
try:
|
| 19 |
if end_time == "":
|
| 20 |
# Create input stream from start_time to end of video
|
| 21 |
stream = ffmpeg.input(file_path, ss=start_time)
|
| 22 |
else:
|
| 23 |
+
time_obj = datetime.strptime(start_time, "%M:%S.%f")
|
| 24 |
+
start_time = time_obj.minute * 60 + time_obj.second + time_obj.microsecond / 1_000_000
|
| 25 |
+
time_obj = datetime.strptime(end_time, "%M:%S.%f")
|
| 26 |
+
end_time = time_obj.minute * 60 + time_obj.second + time_obj.microsecond / 1_000_000
|
| 27 |
# Create input stream with trimming
|
| 28 |
stream = ffmpeg.input(file_path, ss=start_time, t=end_time - start_time)
|
| 29 |
video = stream.video
|