File size: 982 Bytes
091117d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from vitpose import VitPose
import requests
import os
from fastapi import UploadFile
from config import API_URL
import time

def process_video(video_path: str,vitpose: VitPose,user_id: str):
        
    new_file_name = video_path.split(".")[0] + "edited." + video_path.split(".")[1]
    new_file_name = os.path.join("static", new_file_name)
    
    vitpose.output_video_path = new_file_name
    annotated_frames = vitpose.run(video_path)
    annotated_video_path = vitpose.frames_to_video(annotated_frames,rotate=True)
    
    with open(annotated_video_path, "rb") as f:
        contents = f.read()
        
    url = API_URL+ "/excercises/webhooks/video-processed"
    
    files = {"file": (annotated_video_path, contents, "video/mp4")}
    response = requests.post(url, files=files, data={"user_id":user_id,"typeMessage":"video_processed","file_name":annotated_video_path}, stream=True)
    print(response.json())
    os.remove(video_path)
    os.remove(annotated_video_path)