Spaces:
Paused
Paused
Commit
·
4587aee
1
Parent(s):
0e4a709
fix
Browse files
video.py
CHANGED
@@ -2,7 +2,6 @@ import os
|
|
2 |
import logging
|
3 |
import uuid
|
4 |
from ffmpy import FFmpeg
|
5 |
-
from urllib.parse import quote
|
6 |
|
7 |
# Set up logging
|
8 |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
@@ -18,19 +17,15 @@ def ffmpeg_stream(file_url, token, output_dir="tmp/cache/stream"):
|
|
18 |
# Set the output paths
|
19 |
output_path = os.path.join(stream_dir, 'output.m3u8')
|
20 |
segment_filename = os.path.join(stream_dir, 'segment_%03d.ts')
|
21 |
-
|
22 |
-
# URL encode the file URL
|
23 |
-
file_url = quote(file_url, safe=':/')
|
24 |
-
|
25 |
# Construct the FFmpeg command using ffmpy
|
26 |
-
headers = f"Authorization: Bearer {token}"
|
27 |
ff = FFmpeg(
|
28 |
inputs={file_url: None},
|
29 |
outputs={
|
30 |
output_path: f'-c:v libx264 -crf 23 -preset medium -c:a aac -b:a 192k -f hls '
|
31 |
f'-hls_time 10 -hls_list_size 0 -hls_segment_filename {segment_filename}'
|
32 |
},
|
33 |
-
global_options=
|
34 |
)
|
35 |
|
36 |
try:
|
|
|
2 |
import logging
|
3 |
import uuid
|
4 |
from ffmpy import FFmpeg
|
|
|
5 |
|
6 |
# Set up logging
|
7 |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
17 |
# Set the output paths
|
18 |
output_path = os.path.join(stream_dir, 'output.m3u8')
|
19 |
segment_filename = os.path.join(stream_dir, 'segment_%03d.ts')
|
20 |
+
file_url = "'"+file_url+"'"
|
|
|
|
|
|
|
21 |
# Construct the FFmpeg command using ffmpy
|
|
|
22 |
ff = FFmpeg(
|
23 |
inputs={file_url: None},
|
24 |
outputs={
|
25 |
output_path: f'-c:v libx264 -crf 23 -preset medium -c:a aac -b:a 192k -f hls '
|
26 |
f'-hls_time 10 -hls_list_size 0 -hls_segment_filename {segment_filename}'
|
27 |
},
|
28 |
+
global_options=f'-headers \"Authorization: Bearer {token}\r\n"'
|
29 |
)
|
30 |
|
31 |
try:
|