DEV Community

Cover image for Simple SDK to enable visual video search on mobile !
mobileExpert
mobileExpert

Posted on

Simple SDK to enable visual video search on mobile !

Framework
GitHub repository https://github.com/v-modal/vmodal_sdk_flutter is the official Flutter SDK for V-Modal AI, a developer platform built for multimodal search capabilities.

Under the tagline "Search anything anywhere SDK," it enables mobile developers to integrate advanced, AI-driven search into Android and iOS applications. [1, 2]

Core Purpose for Video Search

While V-Modal AI operates as a broad multimodal framework, it functions as a powerful tool for video search by indexing visual, textual, and temporal elements within video files. Instead of relying solely on titles, tags, or basic metadata, it allows developers to build software capable of deep content analysis.

Key Capabilities

  • Semantic Video Search: Allows users to query video libraries using natural conversational language (e.g., searching for "dog jumping over a fence in the rain" to pinpoint the exact moment it occurs).
  • Multimodal Indexing: Parses diverse data inputs—including raw video frames, audio tracks, speech-to-text transcripts, and embedded text—into unified vector embeddings.
  • Cross-Platform Delivery: Provides a native Flutter interface so developers can implement these complex backend AI searches seamlessly into cross-platform mobile apps using a unified Dart codebase. [1]

Example of code:

Because vmodal_sdk_flutter is a specialized, proprietary framework, the following production-style template outlines how to integrate a modern vector-based multimodal search SDK into a Flutter application.
This layout demonstrates how to initialize the client, index a video source, and perform a semantic content query to find timestamp intervals matching natural language.

1. Initialization and Configuration

Initialize your search client using your application API credentials.

import 'package:flutter/material.dart';// Note: Substitute with the exact package name exposed by the repositoryimport 'package:vmodal_sdk_flutter/vmodal_sdk_flutter.dart'; 
void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize the V-Modal Client globally
  await VModal.initialize(
    apiKey: "YOUR_VMODAL_API_KEY",
    environment: VModalEnvironment.production,
  );

  runApp(const MyApp());
}
Enter fullscreen mode Exit fullscreen mode

2. Indexing a Video File

Before searching, you must process and index the video so the AI can build structural vector layers of the visual frames and dialogue transcripts.

Future<String> indexVideoContent(String videoUrlOrPath) async {
  try {
    // Generate a unique index channel for your video collection
    VModalIndexResult result = await VModal.client.indexVideo(
      source: videoUrlOrPath,
      options: VModalIndexOptions(
        enableOcr: true,         // Index text on screen
        enableAudio: true,       // Extract spoken dialogue transcription
        accuracy: IndexAccuracy.high,
      ),
    );

    // Returns the unique Video ID assigned by the indexer
    return result.videoId; 
  } catch (e) {
    debugPrint("Failed to parse and index video: $e");
    rethrow;
  }
}
Enter fullscreen mode Exit fullscreen mode

3. Executing a Semantic Search

Query your video catalog using raw natural language sentences instead of relying on keywords or file names. [1, 2]

class VideoSearchService {

  Future<List<VModalSearchMatch>> searchInsideVideo({
    required String videoId, 
    required String naturalLanguageQuery,
  }) async {
    try {
      // Execute multimodal search query
      VModalSearchResult response = await VModal.client.search(
        videoId: videoId,
        query: naturalLanguageQuery,
        searchType: SearchType.semantic,
      );

      // Return a list of specific match instances containing timestamps
      return response.matches; 
    } catch (e) {
      debugPrint("Search execution error: $e");
      return [];
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

4. Handling and Displaying Time Segments

Iterate over your matched hits to jump directly to the precise seconds where the action occurs in your video player UI.

void displaySearchResults(List<VModalSearchMatch> matches) {
  for (var match in matches) {
    // The timestamp range where the match was identified
    double startInSeconds = match.timeRange.start;
    double endInSeconds = match.timeRange.end;

    // Confidence score generated by the AI architecture (0.0 to 1.0)
    double confidence = match.confidenceScore; 

    debugPrint("Found highly matching segment at: $startInSeconds to $endInSeconds seconds (Confidence: $confidence)");
  }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)