Skip to content

LdDl/mjpeg-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MJPEG server in Rust

Table of Contents

About

Just a template code for serving MJPEG stream via OpenCV.

Yes, this repo code is stolen (highly inspired if you want to) from https://github.com/dskkato/mjpeg-rs and in https://github.com/t924417424/mjpeg_rs.

What the purpose then? Well, I've change a couple of things:

  • Eliminate use of image crate for encoding purposes. Is slows down MJPEG streaming for me drastically. I use imencode instead.
  • Separated thread for MJPEG streaming (proof of concept)
  • Bump to latest actix-web web framework

Usage

Just modify Rust code in main file to adjust your needs:

    // ...
    // Path to video (could be rtsp or local video file)
    let video_src_path = "rtsp://rtsp.stream/pattern".to_string();
    // let video_src_path = "./data/sample_960_540.mp4".to_string();
    // ...
    // ...
    // Change host and port for live streaming if needed
    start_mjpeg_streaming("localhost".to_string(), 8090, rx_mjpeg, first_frame_cols, first_frame_rows) {
    // ...

Start:

cargo run

Open http://localhost:8090/live in browser and enjoy

There would be opened imshow() object also (don't close it accidenlty since main thread will be terminated).

Credits

Thanks to:

Releases

No releases published

Packages

No packages published