Tauri + FFprobe

This is on how to setup FFprobe for tauri

Tauri + FFprobe

You will need a Tauri and Rust installed obviously

  1. Add the ffprobe dependency by running: cargo add ffprobe
  2. Add custom convertion to your rust file
fn to_json<T: serde::Serialize>(data: T) -> Result<String, serde_json::Error> {
    serde_json::to_string(&data)
}
  1. Add a tauri command:
#[tauri::command]
fn ffprobe(path: String) -> Result<String, ()> {
    println!("path: {:?}", path);
    // Open the input file
    let ictx = match ffprobe::ffprobe(&path) {
        Ok(ictx) => ictx,
        Err(e) => {
            eprintln!("ffprobe error: {}", e);
            return Err(());
        },
    };
    let output = to_json(ictx).unwrap();
    Ok(output)
}
  1. Add the command to the invoke_handler in the main function
  2. Test the command:
import { invoke } from "@tauri-apps/api/core";

invoke("ffprobe", { path: p?.path }).then((result) => {
  console.log("ffprobe: ", result);
}).catch((error) => {
  console.error("FFProbe error: ", error)
})

Understanding the output

Streams

This list the media that is embed into the file

Format

Shows the encoding, size, duration and tags

Example