Spaces:
Sleeping
Sleeping
Commit
·
c78f8d1
1
Parent(s):
aec5d3a
Fix video & PPT generation to use /tmp directories for Hugging Face
Browse files- app/api/v1/video.py +3 -1
- app/services/video_service - Copy.py +0 -35
app/api/v1/video.py
CHANGED
|
@@ -28,7 +28,9 @@ def generate_video_endpoint(
|
|
| 28 |
script=payload.prompt,
|
| 29 |
duration=10 # Optional: could be dynamic
|
| 30 |
)
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
if not os.path.exists(video_path):
|
| 34 |
raise HTTPException(status_code=500, detail="Video not found")
|
|
|
|
| 28 |
script=payload.prompt,
|
| 29 |
duration=10 # Optional: could be dynamic
|
| 30 |
)
|
| 31 |
+
output_dir = "/tmp/video"
|
| 32 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 33 |
+
video_path = os.path.join(output_dir, filename)
|
| 34 |
|
| 35 |
if not os.path.exists(video_path):
|
| 36 |
raise HTTPException(status_code=500, detail="Video not found")
|
app/services/video_service - Copy.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
# app/services/video_service.py
|
| 2 |
-
import os
|
| 3 |
-
from datetime import datetime
|
| 4 |
-
from app.db import SessionLocal
|
| 5 |
-
from app.models import MediaGeneration
|
| 6 |
-
import logging
|
| 7 |
-
logger = logging.getLogger(__name__)
|
| 8 |
-
|
| 9 |
-
def generate_video_file(script: str, duration: int = 10) -> str:
|
| 10 |
-
try:
|
| 11 |
-
# Simulate saving a generated video file
|
| 12 |
-
filename = f"video_{datetime.now().strftime('%Y%m%d_%H%M%S')}.mp4"
|
| 13 |
-
folder = "generated/video"
|
| 14 |
-
os.makedirs(folder, exist_ok=True)
|
| 15 |
-
|
| 16 |
-
# Placeholder: Simulate video generation by writing script info to a file
|
| 17 |
-
with open(os.path.join(folder, filename), "w") as f:
|
| 18 |
-
f.write(f"Script: {script}\nDuration: {duration} seconds")
|
| 19 |
-
logger.info(f"Generated Video: {filename}")
|
| 20 |
-
return filename
|
| 21 |
-
except:
|
| 22 |
-
logger.error(f"Video generation failed: {str(e)}")
|
| 23 |
-
raise
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
def save_metadata(media_type, prompt, file_path):
|
| 27 |
-
db = SessionLocal()
|
| 28 |
-
record = MediaGeneration(
|
| 29 |
-
media_type=media_type,
|
| 30 |
-
prompt=prompt,
|
| 31 |
-
file_path=file_path,
|
| 32 |
-
)
|
| 33 |
-
db.add(record)
|
| 34 |
-
db.commit()
|
| 35 |
-
db.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|