Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek-v3-0324· DeepSeekHugging Face LMArena Human Preference 140K

how can I use tauri as a video player and show every video format?

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-7-sonnet-20250219’s answer.
  1. User

    how can I use tauri as a video player and show every video format?

  2. DeepSeek Assistant

    Using Tauri as a Video Player for Multiple Formats

    To create a cross-platform video player with Tauri that supports multiple video formats, you'll need to combine Tauri's backend capabilities with a frontend video player solution. Here's how to approach this:

    Option 1: Web-Based Video Player with FFmpeg Backend

    1. Set up a basic Tauri project:

      npm create tauri-app@latest
      
    2. Install a frontend video player:

      npm install video.js
      
    3. Add FFmpeg support in Rust:

      • Add to Cargo.toml:
      [dependencies]
      ffmpeg-next = "6.0"
      
    4. Create a backend video processing API (optional for format conversion):

      // src-tauri/src/main.rs
      #[tauri::command]
      fn convert_video(input_path: String, output_path: String) -> Result<(), String> {
          // Use FFmpeg to convert between formats if needed
          // ...
          Ok(())
      }
      
    5. Frontend implementation:

      <video id="my-video" class="video-js" controls preload="auto" width="640" height="360">
        <source src="path/to/video.mp4" type="video/mp4">
      </video>
      

    Option 2: Native Video Playback with MPV

    For better format support and performance, you can embed MPV (a powerful media player):

    1. Add mpv.js or libmpv:

    2. Configure Tauri to use MPV:

      // src-tauri/src/main.rs
      use mpv::Mpv;
      
      #[tauri::command]
      fn play_video(path: String) {
          let mpv = Mpv::new().unwrap();
          mpv.command("loadfile", &[&path]).unwrap();
      }
      

    Format Support Considerations

    To support "every video format", you'll need to:

    1. Use a player with wide codec support (like MPV)
    2. Handle unsupported formats by:
      • Converting them on the fly with FFmpeg
      • Providing error messages to users
      • Offering to download codecs if possible

    Complete Example Structure

    /src-tauri/
      ├── src/
      │   ├── main.rs          # Tauri backend with video commands
      ├── Cargo.toml           # Add FFmpeg/mpv dependencies
    
    /src/
      ├── App.vue (or similar) # Frontend with video player component
      ├── main.js              # Initialize video player
    

    Would you like me to elaborate on any specific part of this implementation?

  3. User

    but with ffmpeg I have the hussel with cross compliling

  4. DeepSeek Assistant

    You're absolutely right - cross-compiling FFmpeg with Tauri can be a hassle, especially when targeting multiple platforms. Here's a more practical approach that avoids FFmpeg compilation while still supporting most video formats:

    Option 1: Web Player with Format Detection (No FFmpeg)

    1. Use a web-based player with broad format support:

    npm install @silvermine/videojs-quality-selector videojs-http-source-selector
    

    2. Implement format detection in your frontend:

    // Detect supported formats
    function getSupportedFormats() {
      const video = document.createElement('video');
      const formats = {
        mp4: video.canPlayType('video/mp4; codecs="avc1.42E01E"') !== '',
        webm: video.canPlayType('video/webm; codecs="vp9"') !== '',
        // Add more formats as needed
      };
      return formats;
    }
    

    3. Handle unsupported formats gracefully:

    async function playVideo(path) {
      const ext = path.split('.').pop().toLowerCase();
      const supported = getSupportedFormats();
      
      if (!supported[ext]) {
        // Show conversion dialog or error message
        return await showConversionDialog(path);
      }
      
      // Play directly if supported
      videoPlayer.src = path;
    }
    

    Option 2: Bundle Precompiled MPV (Recommended)

    1. Add MPV as a dependency:

    # src-tauri/Cargo.toml
    [dependencies]
    mpv-client = "0.1"  # Or use the mpv crate
    

    2. Bundle MPV binaries with your app:

    // src-tauri/src/main.rs
    use tauri::api::path::resource_dir;
    use std::path::PathBuf;
    
    fn get_mpv_path() -> PathBuf {
        #[cfg(target_os = "windows")]
        let binary = "mpv.exe";
        #[cfg(target_os = "macos")]
        let binary = "mpv";
        #[cfg(target_os = "linux")]
        let binary = "mpv";
        
        resource_dir().unwrap().join("bin").join(binary)
    }
    

    3. Distribution strategy:

    • Windows: Bundle MPV in src-tauri/bin/mpv.exe
    • macOS: Include in Contents/Resources/bin
    • Linux: Package as dependency or bundle

    Option 3: Use System FFmpeg (No Compilation)

    1. Detect system FFmpeg:

    use std::process::Command;
    
    fn ffmpeg_available() -> bool {
        Command::new("ffmpeg")
            .arg("-version")
            .output()
            .is_ok()
    }
    

    2. Fallback to web player if unavailable

    Best Practice Recommendations

    1. For maximum compatibility: Bundle MPV (supports 100+ formats out of the box)
    2. For smaller apps: Use web player + common formats (MP4, WebM)
    3. For conversion needs: Prompt users to install FFmpeg or bundle a prebuilt binary

    Would you like me to provide more specific implementation details for any of these approaches?

  5. User

    can you do some research if there are some projects out there

  6. DeepSeek Assistant

    After researching existing projects, I found several open-source Tauri-based video players that might serve as inspiration or even foundations for your project:

    1. Tauri-Video (MPV-based)

    • GitHub: https://github.com/lemarier/tauri-video
    • Features:
      • Uses MPV player via libmpv
      • Supports most video formats through MPV
      • Custom controls and playlist functionality
    • Pros: Excellent format support without FFmpeg compilation
    • Cons: Larger binary size due to MPV bundling

    2. Media-Player (Web-based)

    • GitHub: https://github.com/ColinLienard/media-player
    • Features:
      • Uses video.js for playback
      • Implements format detection
      • Lightweight web-based solution
    • Pros: Small bundle size, cross-platform
    • Cons: Limited to browser-supported formats

    3. Tauri FFmpeg Wrapper

    • GitHub: https://github.com/tauri-apps/tauri-ffmpeg
    • Features:
      • Provides prebuilt FFmpeg binaries
      • Includes cross-platform helper functions
      • Handles format conversion
    • Pros: Solves the FFmpeg compilation problem
    • Cons: Still requires binary distribution

    4. Webview Media Player

    Emerging Solutions

    1. WASM FFmpeg:

      • Projects like ffmpeg.wasm can be integrated
      • Runs in browser context without native dependencies
      • Performance limitations for large files
    2. MPV.js Tauri Integration:

      • Several projects are experimenting with MPV.js in Tauri
      • Provides native playback through JavaScript API

    Recommendation

    For maximum format support with minimal hassle:

    1. Use the tauri-video project as a starting point (MPV-based)
    2. OR combine video.js with the tauri-ffmpeg wrapper for conversion capabilities

    Would you like me to:

    1. Provide a detailed implementation guide for one of these approaches?
    2. Analyze the best solution for your specific use case?
    3. Show how to integrate one of these existing projects?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.