Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,11 +13,6 @@ import boto3
|
|
| 13 |
import s3fs
|
| 14 |
import os
|
| 15 |
|
| 16 |
-
# Change the maximum file upload size
|
| 17 |
-
max_upload_size = 25 * 1024 * 1024 * 1024 # 25 GB
|
| 18 |
-
st.set_option('deprecation.showfileUploaderEncoding', False)
|
| 19 |
-
st.set_option('deprecation.fileUploaderMaxSize', max_upload_size)
|
| 20 |
-
|
| 21 |
# Define output directory
|
| 22 |
output_dir = Path.cwd() / "output"
|
| 23 |
output_dir.mkdir(exist_ok=True)
|
|
@@ -32,9 +27,6 @@ session = boto3.Session(
|
|
| 32 |
region_name='us-east-1'
|
| 33 |
)
|
| 34 |
|
| 35 |
-
s3 = session.client('s3')
|
| 36 |
-
fs = s3fs.S3FileSystem(anon=False, client_kwargs={'region_name': 'us-east-1'})
|
| 37 |
-
|
| 38 |
logging.basicConfig(level=logging.INFO)
|
| 39 |
|
| 40 |
standard_resolutions = [4320, 2160, 1440, 1080, 720, 480, 360, 240]
|
|
@@ -113,12 +105,15 @@ def upload_file_to_s3(local_path, s3_key):
|
|
| 113 |
|
| 114 |
return f"https://{bucket_name}.s3.amazonaws.com/{s3_key}"
|
| 115 |
|
| 116 |
-
|
| 117 |
def convert_video(video_file, quality, aspect_ratio, video_url):
|
| 118 |
# Ensure either a file or a URL is provided
|
| 119 |
if not video_file and not video_url:
|
| 120 |
raise ValueError("Please provide either a video file or a video URL.")
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
input_path = get_input_path(video_file, video_url)
|
| 123 |
st.write(f"Input file path: {input_path}") # Added line to print input file path
|
| 124 |
video = VideoFileClip(str(input_path))
|
|
@@ -167,7 +162,7 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
| 167 |
st.title("NEAR Hub Video Transcoder to m3u8")
|
| 168 |
st.markdown("Convert video files to m3u8 for VOD streaming in nearhub.club.")
|
| 169 |
|
| 170 |
-
video_file = st.file_uploader("Your video file")
|
| 171 |
quality = st.slider("Quality (0: Highest Quality - 50: Fastest)", min_value=0, max_value=51, value=23)
|
| 172 |
aspect_ratio = st.selectbox("Aspect Ratio", ["16:9", "4:3", "1:1", "3:4", "9:16", "1:1", "2:1", "1:2"], index=0)
|
| 173 |
video_url = st.text_input("Video URL", "")
|
|
|
|
| 13 |
import s3fs
|
| 14 |
import os
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Define output directory
|
| 17 |
output_dir = Path.cwd() / "output"
|
| 18 |
output_dir.mkdir(exist_ok=True)
|
|
|
|
| 27 |
region_name='us-east-1'
|
| 28 |
)
|
| 29 |
|
|
|
|
|
|
|
|
|
|
| 30 |
logging.basicConfig(level=logging.INFO)
|
| 31 |
|
| 32 |
standard_resolutions = [4320, 2160, 1440, 1080, 720, 480, 360, 240]
|
|
|
|
| 105 |
|
| 106 |
return f"https://{bucket_name}.s3.amazonaws.com/{s3_key}"
|
| 107 |
|
|
|
|
| 108 |
def convert_video(video_file, quality, aspect_ratio, video_url):
|
| 109 |
# Ensure either a file or a URL is provided
|
| 110 |
if not video_file and not video_url:
|
| 111 |
raise ValueError("Please provide either a video file or a video URL.")
|
| 112 |
|
| 113 |
+
# Check file size
|
| 114 |
+
if video_file is not None and video_file.size > max_upload_size:
|
| 115 |
+
raise ValueError("Maximum file size exceeded. Please upload a smaller file.")
|
| 116 |
+
|
| 117 |
input_path = get_input_path(video_file, video_url)
|
| 118 |
st.write(f"Input file path: {input_path}") # Added line to print input file path
|
| 119 |
video = VideoFileClip(str(input_path))
|
|
|
|
| 162 |
st.title("NEAR Hub Video Transcoder to m3u8")
|
| 163 |
st.markdown("Convert video files to m3u8 for VOD streaming in nearhub.club.")
|
| 164 |
|
| 165 |
+
video_file = st.file_uploader("Your video file", type=["mp4", "mov"])
|
| 166 |
quality = st.slider("Quality (0: Highest Quality - 50: Fastest)", min_value=0, max_value=51, value=23)
|
| 167 |
aspect_ratio = st.selectbox("Aspect Ratio", ["16:9", "4:3", "1:1", "3:4", "9:16", "1:1", "2:1", "1:2"], index=0)
|
| 168 |
video_url = st.text_input("Video URL", "")
|