🎵

Muzibu HLS Sistemi

Gereksinimler, Encryption, Kullanım ve Bulk Conversion

📋
Gereksinimler
HLS için ne gerekli?
🔐
Encryption
AES-128 detayları
⚙️
Dönüşüm
Nasıl çalışır?
📦
Bulk Convert
Toplu dönüştürme

📋 Bir Şarkının HLS'e Hazır Olması İçin Gereksinimler

1. Database Kayıtları (muzibu_songs)

Field Gerekli Mi? Açıklama
hls_path ZORUNLU Playlist.m3u8 dosyasının relative path'i
muzibu/hls/{song_id}/playlist.m3u8
encryption_key ZORUNLU 128-bit AES key (32 karakter hex)
örn: 287a99631a3028a6f28247bc5604fbcc
encryption_iv ZORUNLU 128-bit Initialization Vector (32 karakter hex)
örn: bee092188df6e046503f34b3f4103511
file_path FALLBACK MP3 dosyası (HLS fail olursa fallback)
song_xxxxx.mp3

2. File System (Storage)

HLS Klasör Yapısı:
storage/tenant{id}/app/public/muzibu/hls/{song_id}/
├── playlist.m3u8 (ZORUNLU - HLS playlist)
├── enc.key (ZORUNLU - 16 bytes binary)
├── enc.keyinfo (Optional - FFmpeg için)
├── playlist0.ts (Segment 1)
├── playlist1.ts (Segment 2)
├── playlist2.ts (Segment 3)
└── ...
Minimum Gereksinimler:
✓ playlist.m3u8
HLS playlist file (text)
✓ enc.key
16 bytes binary key
✓ *.ts segments
10 saniye chunks

3. API Endpoint (Key Serving)

Encryption Key Endpoint:
GET https://muzibu.com/api/muzibu/songs/{song_id}/key
Response:
HTTP/2 200 OK
Content-Type: application/octet-stream
Content-Length: 16
Cache-Control: public, max-age=31536000
[16 bytes binary data]

🔐 Encryption Sistemi (AES-128)

Nasıl Çalışır?

1
Key Generation
Random 128-bit key + IV oluşturulur
bin2hex(random_bytes(16))
2
Database'e Kaydet
encryption_key ve encryption_iv database'e yazılır
3
Binary Key File
Key hex'ten binary'e dönüştürülüp enc.key olarak kaydedilir (16 bytes)
4
FFmpeg Encryption
MP3 → HLS dönüşümünde her segment AES-128 ile şifrelenir
5
Playlist Key URI
playlist.m3u8'de key URL'i belirtilir: URI="https://.../{song_id}/key"
6
Player Request
HLS.js playlist'i okur, key URL'den enc.key'i indirir, segment'leri decrypt eder

Key Endpoint (serveKey)

Dosya: SongStreamController.php
// Storage'dan binary key dosyası oku
$keyPath = storage_path("app/public/muzibu/hls/{$songId}/enc.key");
$keyContent = file_get_contents($keyPath);
// Binary olarak serve et (16 bytes)
return response($keyContent, 200)
->header('Content-Type', 'application/octet-stream')
->header('Content-Length', strlen($keyContent))
->header('Cache-Control', 'public, max-age=31536000')
->header('Access-Control-Allow-Origin', '*');

Playlist.m3u8 Örneği

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="https://muzibu.com/api/muzibu/songs/458/key",IV=0x5c88a373f5facc1a53a4cdb3ec453b07
#EXTINF:10.005333,
playlist0.ts
#EXTINF:9.994667,
playlist1.ts
...

⚙️ HLS Conversion Süreci

ConvertToHLSJob Flow

1
MP3 Dosya Kontrolü
storage/tenant{id}/app/public/muzibu/songs/{file_path}
2
HLS Klasör Oluştur
storage/tenant{id}/app/public/muzibu/hls/{song_id}/
3
Encryption Key Oluştur
• Random 128-bit key + IV
• Database'e kaydet (hex format)
• enc.key dosyası oluştur (binary)
• enc.keyinfo oluştur (FFmpeg için)
4
FFmpeg ile HLS Dönüşümü
ffmpeg -i input.mp3 \
  -c:a aac -b:a {bitrate}k \
  -af "loudnorm,stereotools,equalizer,..." \
  -hls_time 10 \
  -hls_key_info_file enc.keyinfo \
  -f hls playlist.m3u8
5
Database Güncelle
hls_path = "muzibu/hls/{id}/playlist.m3u8"
6
Cache Invalidate
Song cache temizle (güncel HLS bilgisi için)

Audio Filters (Ultimate Edition)

Loudnorm
LUFS-based loudness normalization
Stereotools
Stereo widening (mlev=1.2)
Equalizer (Bass)
+1dB @ 100Hz boost
Equalizer (Treble)
-2dB @ 8kHz cut
Lowpass
14kHz filter

📦 Bulk HLS Convert Özelliği

Özellik

HLS olmayan (MP3 olarak kalmış) şarkıları toplu olarak HLS formatına dönüştürme aracı.

🔍
Otomatik Filtreleme
hls_path = NULL olan şarkıları listeler
☑️
Çoklu Seçim
Checkbox ile istediğin kadar seç
Queue İşleme
Arka planda otomatik dönüşüm

Nasıl Kullanılır?

1
Sayfaya Git
Admin → Muzibu → Songs → Bulk HLS Convert
/admin/muzibu/song/bulk-convert
2
Şarkıları Seç
• Checkbox ile tek tek seç
• "Tümünü Seç" ile hepsini seç
• Arama ile filtrele
3
Dönüştür
"HLS'e Dönüştür (X)" butonuna tıkla
→ Job'lar kuyruğa eklenir
→ Horizon otomatik işler
→ Şarkılar HLS'e dönüşür

Kod Detayları

Component:
SongBulkConvertComponent.php
View:
song-bulk-convert-component.blade.php
Route:
GET /admin/muzibu/song/bulk-convert

Özet

HLS Gereksinimi: hls_path + encryption_key + encryption_iv + enc.key dosyası + playlist.m3u8 + segments
Encryption: AES-128 ile her segment şifrelenir, key API endpoint ile serve edilir
Dönüşüm: ConvertToHLSJob ile otomatik (Horizon queue), FFmpeg + audio filters
Bulk Convert: HLS olmayan şarkıları toplu seçip dönüştürme (checkbox + queue)

Muzibu HLS Sistemi Dokümantasyonu - 17 Aralık 2025

Generated with Claude Code