Skip to content

silvermine/tauri-plugin-media-parser

Repository files navigation

Tauri Media Parser Plugin

CI

A Tauri plugin to parse MP4 files: extract metadata, tracks, frames, and subtitles. Async API for getting info from local files or HTTP streams.

Project Structure

This project is organized as a Cargo workspace with the following structure:

tauri-plugin-media-parser/
├── crates/
│   └── media-parser/          # Rust MP4 parser library
│       ├── src/
│       │   ├── errors.rs
│       │   ├── lib.rs
│       │   ├── stream.rs
│       │   └── types.rs
│       └── Cargo.toml
├── src/                        # Tauri plugin implementation
│   ├── commands.rs             # Plugin commands
│   ├── error.rs                 # Error types
│   └── lib.rs                   # Main plugin code
├── guest-js/                    # JavaScript/TypeScript bindings
│   ├── index.ts
│   └── tsconfig.json
├── permissions/                 # Permission definitions (mostly generated)
├── dist-js/                     # Compiled JS (generated)
├── Cargo.toml                   # Workspace configuration
├── package.json                 # NPM package configuration
└── build.rs                     # Build script

Crates

media-parser

A Rust module with no dependencies on Tauri or its plugin architecture. It provides an async API for parsing MP4 media files, extracting metadata, tracks, subtitles, and frames from local files or HTTP streams. It's designed to be published as a standalone crate in the future with minimal changes.

See crates/media-parser/README.md for more details.

Tauri Plugin

The main plugin provides a Tauri integration layer that exposes media parsing functionality to Tauri applications. It uses the media-parser module internally.

Getting Started

Installation

  1. Install NPM dependencies:

    npm install
  2. Build the TypeScript bindings:

    npm run build
  3. Build the Rust plugin:

    cargo build

Tests

Run Rust tests:

cargo test

Linting and standards checks

npm run standards

Usage

In a Tauri Application

Add the plugin to your Tauri application's Cargo.toml:

[dependencies]
tauri-plugin-media-parser = { path = "../path/to/tauri-plugin-media-parser" }

Add the plugin permission to your capabilities file src-tauri/capabilities/default.json

{
  "permissions": [
    "core:default",
    "media-parser:default"
  ]
}

Initialize the plugin in your Tauri app:

fn main() {
    tauri::Builder::default()
        .plugin(tauri_plugin_media_parser::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

JavaScript/TypeScript API

Install the JavaScript package in your frontend:

npm install @silvermine/tauri-plugin-media-parser

Use the plugin from JavaScript/TypeScript:

import { hello } from '@silvermine/tauri-plugin-media-parser';

// Call the hello command
const greeting = await hello('World');
console.log(greeting); // "Hello, World! This is the Media Parser plugin."

Development Standards

This project follows the Silvermine standardization guidelines. Key standards include:

  • EditorConfig: Consistent editor settings across the team
  • Markdownlint: Markdown linting for documentation
  • Commitlint: Conventional commit message format
  • Code Style: 3-space indentation, LF line endings

Running Standards Checks

npm run standards

License

MIT

Contributing

Contributions are welcome! Please follow the established coding standards and commit message conventions.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •