Spaces:
Build error
Build error
Commit
·
0bbba4e
1
Parent(s):
f505705
fix video
Browse files
video.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import os
|
| 2 |
import subprocess
|
| 3 |
import logging
|
|
@@ -7,19 +8,14 @@ import uuid
|
|
| 7 |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 8 |
|
| 9 |
def ffmpeg_stream(file_url, token, output_dir="tmp/cache/stream"):
|
| 10 |
-
|
| 11 |
-
stream_id = str(uuid.uuid4())
|
| 12 |
-
stream_dir = os.path.join(output_dir, stream_id)
|
| 13 |
|
| 14 |
if not os.path.exists(stream_dir):
|
| 15 |
os.makedirs(stream_dir)
|
| 16 |
-
logging.info(f"Created directory: {stream_dir}")
|
| 17 |
-
else:
|
| 18 |
-
logging.info(f"Directory already exists: {stream_dir}")
|
| 19 |
|
| 20 |
# Set up the FFmpeg command for HLS
|
| 21 |
-
output_path =
|
| 22 |
-
segment_filename =
|
| 23 |
|
| 24 |
ffmpeg_command = [
|
| 25 |
'ffmpeg',
|
|
@@ -68,7 +64,6 @@ def ffmpeg_stream(file_url, token, output_dir="tmp/cache/stream"):
|
|
| 68 |
logging.error(f"Error using FFmpeg to stream file: {e}")
|
| 69 |
return None, None
|
| 70 |
|
| 71 |
-
# # Example usage
|
| 72 |
# if __name__ == "__main__":
|
| 73 |
# url = "https://huggingface.co/Unicone-Studio/jellyfin_media/resolve/main/films/Funky%20Monkey%202004/Funky%20Monkey%20(2004)%20Web-dl%201080p.mp4"
|
| 74 |
# token = os.getenv("TOKEN")
|
|
|
|
| 1 |
+
from ffmpy import FFmpeg
|
| 2 |
import os
|
| 3 |
import subprocess
|
| 4 |
import logging
|
|
|
|
| 8 |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 9 |
|
| 10 |
def ffmpeg_stream(file_url, token, output_dir="tmp/cache/stream"):
|
| 11 |
+
stream_dir = output_dir
|
|
|
|
|
|
|
| 12 |
|
| 13 |
if not os.path.exists(stream_dir):
|
| 14 |
os.makedirs(stream_dir)
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Set up the FFmpeg command for HLS
|
| 17 |
+
output_path = stream_dir+'/output.m3u8'
|
| 18 |
+
segment_filename = stream_dir+'/segment_%03d.ts'
|
| 19 |
|
| 20 |
ffmpeg_command = [
|
| 21 |
'ffmpeg',
|
|
|
|
| 64 |
logging.error(f"Error using FFmpeg to stream file: {e}")
|
| 65 |
return None, None
|
| 66 |
|
|
|
|
| 67 |
# if __name__ == "__main__":
|
| 68 |
# url = "https://huggingface.co/Unicone-Studio/jellyfin_media/resolve/main/films/Funky%20Monkey%202004/Funky%20Monkey%20(2004)%20Web-dl%201080p.mp4"
|
| 69 |
# token = os.getenv("TOKEN")
|