Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -51,14 +51,14 @@ def convert_video(video_file: File, quality, aspect_ratio, video_url):
|
|
51 |
output_path = video_file.name[:-len(file_extension)]
|
52 |
|
53 |
# Add the .mp4 file extension
|
54 |
-
output_path += ".
|
55 |
|
56 |
# Set the output path to the temp directory
|
57 |
output_path = os.path.join(temp_dir, output_path)
|
58 |
|
59 |
if os.path.exists(output_path):
|
60 |
# The file already exists, so we can just display it in the output viewer
|
61 |
-
gr.
|
62 |
else:
|
63 |
# The file does not exist, so we need to convert it
|
64 |
ffmpeg_command = f"ffmpeg -i {video_file} -c:v libx264 -crf {quality} -f mp4 -aspect {aspect_ratio} {output_path}"
|
@@ -79,7 +79,7 @@ def convert_video(video_file: File, quality, aspect_ratio, video_url):
|
|
79 |
time.sleep(1)
|
80 |
|
81 |
# The file has now been converted, so we can display it in the output viewer
|
82 |
-
gr.
|
83 |
|
84 |
# Create a temporary file to store the download link
|
85 |
with tempfile.NamedTemporaryFile(delete=False) as f:
|
@@ -87,10 +87,10 @@ def convert_video(video_file: File, quality, aspect_ratio, video_url):
|
|
87 |
download_link = f.name
|
88 |
|
89 |
# Add a button to download the file
|
90 |
-
gr.
|
91 |
<a href="{}" download="downloaded_file.mp4">Download</a>
|
92 |
""".format(download_link))
|
93 |
|
94 |
from gradio import outputs
|
95 |
|
96 |
-
gr.Interface(convert_video, inputs=[video_file, quality, aspect_ratio, video_url], outputs=[outputs.Video()]).launch()
|
|
|
51 |
output_path = video_file.name[:-len(file_extension)]
|
52 |
|
53 |
# Add the .mp4 file extension
|
54 |
+
output_path += ".mp4"
|
55 |
|
56 |
# Set the output path to the temp directory
|
57 |
output_path = os.path.join(temp_dir, output_path)
|
58 |
|
59 |
if os.path.exists(output_path):
|
60 |
# The file already exists, so we can just display it in the output viewer
|
61 |
+
gr.components.Video(output_path)
|
62 |
else:
|
63 |
# The file does not exist, so we need to convert it
|
64 |
ffmpeg_command = f"ffmpeg -i {video_file} -c:v libx264 -crf {quality} -f mp4 -aspect {aspect_ratio} {output_path}"
|
|
|
79 |
time.sleep(1)
|
80 |
|
81 |
# The file has now been converted, so we can display it in the output viewer
|
82 |
+
gr.components.Video(output_path)
|
83 |
|
84 |
# Create a temporary file to store the download link
|
85 |
with tempfile.NamedTemporaryFile(delete=False) as f:
|
|
|
87 |
download_link = f.name
|
88 |
|
89 |
# Add a button to download the file
|
90 |
+
gr.components.HTML("""
|
91 |
<a href="{}" download="downloaded_file.mp4">Download</a>
|
92 |
""".format(download_link))
|
93 |
|
94 |
from gradio import outputs
|
95 |
|
96 |
+
gr.Interface(convert_video, inputs=[video_file, quality, aspect_ratio, video_url], outputs=[outputs.Video()]).launch(share=True)
|