crab-dlna is a minimal UPnP/DLNA media streamer, available both as a standlone CLI (command line interface) application and a Rust library.
It allows you to play a local video file in your TV (or any other DLNA compatible device).
In the GitHub Releases of this repository we provide archives of precompiled binaries of crab-dlna, available for Linux, Windows, and macOS.
Installation via cargo is done by installing the crab-dlna
crate:
```bash
rustup update stable
cargo install crab-dlna
cargo install crab-dlna --locked ```
You can list all the CLI commands by running:
crab-dlna --help
Scan compatible devices and list the available ones:
bash
crab-dlna list
If your device is not being listed, you might need to increase the search timeout:
bash
crab-dlna -t 20 list
Play a video, automatically loading the subtitles if available, selecting a random device:
bash
crab-dlna play That.Movie.mkv
Play a video, specifying the device through query (scan devices before playing):
bash
crab-dlna play That.Movie.mkv -q "osmc"
Play a video, specifying the device through its exact location (no scan, faster):
bash
crab-dlna play That.Movie.mkv -d "http://192.168.1.13:1082/"
Add crab-dlna
and tokio
to your dependencies:
toml
[dependencies]
tokio = { version = "1", features = ["full"] }
crab-dlna = "0.2"
crab-dlna provides a function to discover a list devices in the network.
```rust use crab_dlna::Render;
async fn main() { let discovertimeoutsecs = 5; let rendersdiscovered = Render::discover(discovertimeoutsecs).await.unwrap(); for render in rendersdiscovered { println!("{}", render); } } ```
We can specify a DLNA device render trough a query string, and then play a certain video in it, automatically detecting the subtitle file.
```rust use std::path::PathBuf; use crabdlna::{ Render, RenderSpec, MediaStreamingServer, STREAMINGPORTDEFAULT, getlocalip, infersubtitlefromvideo, Error, play, };
async fn main() -> Result<(), Error> { let discovertimeoutsecs = 5; let renderspec = RenderSpec::Query(discovertimeoutsecs, "Kodi".tostring()); let render = Render::new(renderspec).await?; let hostip = getlocalip().await?; let hostport = STREAMINGPORTDEFAULT; let videopath = PathBuf::from("/home/crab/Videos/myvideo.mp4"); let inferredsubtitlepath = infersubtitlefromvideo(&videopath); let mediastreamingserver = MediaStreamingServer::new( &videopath, &inferredsubtitlepath, &hostip, &hostport, )?; play(render, mediastreamingserver).await } ```
You can access the full documentation to see more details about the library.
Copyright (c) 2022 Gabriel Magno.
crab-dlna
is made available under the terms of either the MIT License or the Apache License 2.0, at your option.
See the LICENSE-APACHE and LICENSE-MIT files for license details.