Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
How to use opencv-python to read/decode POSTed video data in Django

I'm building a Django website. My users can record a video and then others can see these videos.

The recording is done with javascript:

const mimeType = 'video/mp4';
shouldStop = false;
const constraints = {
    audio: {
        echoCancellation: true,
        noiseSuppression: true,
    },
    // audio: true,
    video: {
        width:  480,
        height:  480,
        facingMode: 'user',
    },
};
const stream = await navigator.mediaDevices.getUserMedia(constraints);

    const blob = new Blob(recordedChunks, {
        type: mimeType
    });

And the sent to a django view:

 let response = await fetch("/send-video/", {
    
    method: "post",
    body: blob,           
    headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        "X-CSRFToken":csrftoken,
    },
}).then( ... )

In my views

if request.method == 'POST':
    user = request.user
    file_name = f"{user}.mp4"
    if (len(sys.argv) >= 2 and sys.argv[1] == 'runserver'):
        file_path = file_name
    else:
        file_path = f"{your_media_root}temp/{file_name}"
    webm_bytes = bytes(request.body)
    video_file = open(file_path, "wb")
    video_file.write(webm_bytes)

    if mimetypes.guess_type(file_path)[0].startswith('video/mp4'):
        print(mimetypes.guess_type(file_path))
        video_file.close() 
    else: 
        video_file.write(b"")     
        video_file.close() 

I like to understand how I can use opencv-python instead of raw file saving. How can I implement this ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!