Spaces:
Sleeping
Sleeping
add .mov file format
Browse files
app.py
CHANGED
|
@@ -71,7 +71,7 @@ def process_video_in_background(video_data: bytes, video_guid: str, filename: st
|
|
| 71 |
except Exception as e:
|
| 72 |
print(f"DB Error on video insert: {str(e)}")
|
| 73 |
return
|
| 74 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".
|
| 75 |
temp_video_file.write(video_data)
|
| 76 |
temp_path = temp_video_file.name
|
| 77 |
cap = cv2.VideoCapture(temp_path)
|
|
@@ -327,10 +327,7 @@ async def update_frame_status(frame_id: int, payload: dict = Body(...)):
|
|
| 327 |
async def upload_video(background_tasks: BackgroundTasks, location: str = Form(None), category: str = Form(...), city: str = Form(...), file: UploadFile = File(...)):
|
| 328 |
if not file.content_type.startswith('video/'):
|
| 329 |
raise HTTPException(status_code=400, detail="File is not a video.")
|
| 330 |
-
video_data = await file.read()
|
| 331 |
-
# Extract extension from uploaded file (fallback to .mp4)
|
| 332 |
-
ext = os.path.splitext(file.filename)[1]
|
| 333 |
-
ext = ext.lower() if ext.lower() in [".mp4", ".mov"] else ".mp4"
|
| 334 |
video_guid = str(uuid.uuid4())
|
| 335 |
lat, lon = get_gps_location(file.file)
|
| 336 |
location_point = f"Point({lon:.6f} {lat:.6f})" if lat and lon else None
|
|
@@ -348,9 +345,8 @@ async def upload_video(background_tasks: BackgroundTasks, location: str = Form(N
|
|
| 348 |
print(f"variancevalue: {getvariancevalue}")
|
| 349 |
print(f"category: {category}")
|
| 350 |
print(f"Step2")
|
| 351 |
-
print(f"city: {city}")
|
| 352 |
"""
|
| 353 |
-
print(f"
|
| 354 |
background_tasks.add_task(process_video_in_background, video_data, video_guid, file.filename, location_point, location, is_approved, getvariancevalue, category, city)
|
| 355 |
return {"message": "Video upload successful. Processing has started.", "video_guid": video_guid}
|
| 356 |
|
|
|
|
| 71 |
except Exception as e:
|
| 72 |
print(f"DB Error on video insert: {str(e)}")
|
| 73 |
return
|
| 74 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as temp_video_file:
|
| 75 |
temp_video_file.write(video_data)
|
| 76 |
temp_path = temp_video_file.name
|
| 77 |
cap = cv2.VideoCapture(temp_path)
|
|
|
|
| 327 |
async def upload_video(background_tasks: BackgroundTasks, location: str = Form(None), category: str = Form(...), city: str = Form(...), file: UploadFile = File(...)):
|
| 328 |
if not file.content_type.startswith('video/'):
|
| 329 |
raise HTTPException(status_code=400, detail="File is not a video.")
|
| 330 |
+
video_data = await file.read()
|
|
|
|
|
|
|
|
|
|
| 331 |
video_guid = str(uuid.uuid4())
|
| 332 |
lat, lon = get_gps_location(file.file)
|
| 333 |
location_point = f"Point({lon:.6f} {lat:.6f})" if lat and lon else None
|
|
|
|
| 345 |
print(f"variancevalue: {getvariancevalue}")
|
| 346 |
print(f"category: {category}")
|
| 347 |
print(f"Step2")
|
|
|
|
| 348 |
"""
|
| 349 |
+
print(f"city: {city}")
|
| 350 |
background_tasks.add_task(process_video_in_background, video_data, video_guid, file.filename, location_point, location, is_approved, getvariancevalue, category, city)
|
| 351 |
return {"message": "Video upload successful. Processing has started.", "video_guid": video_guid}
|
| 352 |
|