Coder Social home page Coder Social logo

mp4-stream's Introduction

mp4-stream

Repository crates.io docs.rs CI

A fast and easy to use fMP4 streaming implementation.

mp4-stream is an efficient and scalable implementation of fragmented MP4 video streaming. It uses channels to separate video capture and encoding from MP4 muxing, making it possible to stream live video over multiple connections. It can also handle live configuration updates, which require restarting the individual streams, but the video capture worker does not have to be restarted.

Usage

use mp4_stream::{config::Config, VideoStream, stream_media_segments};
use std::{fs, thread, io::Write};

fn main() -> Result<(), Box<dyn std::error::Error> {
    // Create a configuration
    let config = Config::default();
    let config_clone = config.clone();
    // Create a channel to send requests for video data on
    let (tx, rx) = flume::unbounded();
    // Start another thread to capture video and send it on the channel
    thread::spawn(move || {
        stream_media_segments(rx, config_clone, None).unwrap();
    });

    let mut file = fs::File::create("video.mp4")?;
    // Create a stream from the channel
    let stream = VideoStream::new(&config, tx)?;
    // Take the first 10 segments and write them to a file
    for segment in stream.take(10) {
        file.write_all(&segment?)?;
    }
    Ok(())
}

mp4-stream's People

Contributors

norrchr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.