Kino Frequency Analysis
High-performance audio frequency analysis library for Kino's decentralized video platform.
Features
- FFT-based Analysis - Real-time and batch frequency analysis using rustfft
- Audio Fingerprinting - Shazam-style spectral peak constellation for content verification
- AI Auto-Tagging - Rule-based content classification using spectral features
- Thumbnail Generation - 2D FFT-based frame quality scoring
- Recommendations - Frequency signature matching for content similarity
- Solana Integration - On-chain fingerprint storage for verification
- Streaming Analysis - Real-time event-driven processing
Installation
Add to your Cargo.toml:
[]
= { = "../kino-frequency", = ["full"] }
Feature Flags
| Feature | Description |
|---|---|
fingerprint |
Audio fingerprinting with SHA-256 hashing |
tagging |
AI-powered content auto-tagging |
thumbnail |
2D FFT thumbnail selection |
recommend |
Content similarity recommendations |
solana |
On-chain fingerprint storage |
full |
All features enabled |
Quick Start
Basic Analysis
use ;
// Create analyzer
let analyzer = new;
// Analyze audio samples
let analysis = analyzer.analyze?;
println!;
println!;
Audio Fingerprinting
use Fingerprinter;
let fingerprinter = new;
let fingerprint = fingerprinter.fingerprint?;
println!;
println!;
// Verify content
let verification = fingerprinter.verify?;
if verification.is_match
Content Auto-Tagging
use ContentTagger;
let tagger = new;
let tags = tagger.predict?;
for tag in tags
Streaming Analysis
use ;
let config = StreamConfig ;
let mut analyzer = new;
// Register event callbacks
analyzer.on_event;
// Process audio chunks
for chunk in audio_stream
Content Recommendations
use RecommendationEngine;
let mut engine = new;
// Index content
engine.add_content?;
engine.add_content?;
// Find similar content
let similar = engine.get_similar;
for rec in similar
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Video Upload │───▶│ Audio Extract │───▶│ FFT Analysis │
└─────────────────┘ └──────────────────┘ └────────┬────────┘
│
┌───────────────────────────────────────────────┼───────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌────────────────┐ ┌───────────────┐
│ Fingerprint │ │ Auto-Tagging │ │ Recommendations│
│ (SHA-256) │ │ (ML Model) │ │ (Similarity) │
└───────┬───────┘ └────────┬───────┘ └───────┬───────┘
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌────────────────┐ ┌───────────────┐
│ Solana Chain │ │ Content Tags │ │ Similar Items │
│ (Verification)│ │ (Metadata) │ │ (API Response)│
└───────────────┘ └────────────────┘ └───────────────┘
API Reference
Core Types
AudioData
FrequencyAnalysis
BandEnergies
FrequencySignature
FrequencyAnalyzer Methods
| Method | Description |
|---|---|
new(fft_size, hop_size) |
Create analyzer with specified parameters |
analyze(samples, sample_rate) |
Perform full frequency analysis |
dominant_frequencies(samples, sample_rate, top_k) |
Extract top K frequencies |
compute_signature(samples, sample_rate) |
Generate frequency signature |
compute_spectrogram(samples) |
Compute full spectrogram |
bandpass_filter(samples, sample_rate, low, high) |
Apply bandpass filter |
project_to_dominant(samples, sample_rate, top_k) |
Reconstruct with only dominant frequencies |
Streaming Events
| Event | Description |
|---|---|
BeatDetected |
Beat detected with energy and tempo estimate |
SilenceStart |
Start of silence period |
SilenceEnd |
End of silence with duration |
DominantFrequencyChange |
Significant frequency shift |
FrameAnalyzed |
New analysis frame available |
CLI Usage
The Kino CLI includes frequency analysis commands:
# Analyze frequencies
# Generate fingerprint
# Auto-tag content
# Generate thumbnail
# Find similar content
# Full processing pipeline
Python Bindings
Install with maturin:
Usage:
# Analyze audio
=
=
# Generate fingerprint
=
=
# Auto-tag
=
=
WebAssembly
The frequency analysis is available as a WASM module:
import init from 'kino-wasm';
await ;
const analyzer = ;
const result = analyzer.;
console.log;
console.log;
Benchmarks
Run benchmarks:
Typical performance (Apple M1):
| Operation | Duration | Throughput |
|---|---|---|
| FFT 4096 | 45µs | 22,000 ops/s |
| Fingerprint (10s) | 12ms | 83 files/s |
| Signature | 8ms | 125 files/s |
| Similarity | 2µs | 500,000 comparisons/s |
License
MIT OR Apache-2.0