-
Notifications
You must be signed in to change notification settings - Fork 0
Advanced Configuration
DarkWob edited this page Dec 9, 2024
·
1 revision
// ... existing code ...
Supported audio formats and their configurations:
use Darkwob\YoutubeMp3Converter\Converter\Options\ConverterOptions;
$options = new ConverterOptions();
// MP3 Format (Default)
$options->setAudioFormat('mp3')
->setAudioQuality('320k'); // 128k, 192k, 256k, 320k
// AAC Format
$options->setAudioFormat('aac')
->setAudioQuality('256k');
// WAV Format
$options->setAudioFormat('wav')
->setAudioQuality('best');
// FLAC Format
$options->setAudioFormat('flac');
// M4A Format
$options->setAudioFormat('m4a')
->setAudioQuality('192k');
Configure metadata and thumbnails:
$options = new ConverterOptions();
$options
->setAddMetadata(true) // Add ID3 tags
->setAddThumbnail(true) // Embed album art
->setMetadataFields([
'title' => true,
'artist' => true,
'album' => true,
'date' => true,
'description' => false,
'genre' => true
]);
Customize output filenames:
$options = new ConverterOptions();
// Default template
$options->setOutputTemplate('%(title)s.%(ext)s');
// With video ID
$options->setOutputTemplate('%(title)s-%(id)s.%(ext)s');
// With date
$options->setOutputTemplate('%(upload_date)s-%(title)s.%(ext)s');
// Custom directory structure
$options->setOutputTemplate('%(uploader)s/%(title)s.%(ext)s');
Configure network-related options:
$options = new ConverterOptions();
$options
->setProxy('socks5://127.0.0.1:1080') // Use proxy
->setNetworkTimeout(30) // Timeout in seconds
->setMaxRetries(3) // Max retry attempts
->setBufferSize(1024 * 1024) // Buffer size (1MB)
->setRateLimit(500) // Download speed limit (KB/s)
->setForceIpv4(true); // Force IPv4
Configure Redis for progress tracking:
use Darkwob\YoutubeMp3Converter\Progress\RedisProgress;
// Using default Redis connection
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
$progress = new RedisProgress($redis);
// Using Predis client
$predis = new \Predis\Client([
'scheme' => 'tcp',
'host' => '127.0.0.1',
'port' => 6379,
'password' => 'your-password',
'database' => 0
]);
$progress = new RedisProgress($predis);
// Configure TTL (Time To Live)
$progress = new RedisProgress($redis, 7200); // 2 hours
Advanced playlist processing options:
$options = new ConverterOptions();
$options
->setPlaylistStart(1) // Start from first video
->setPlaylistEnd(10) // Process first 10 videos
->setPlaylistItems('1,3,5-7') // Specific videos
->setReversePlaylist(false) // Process in order
->setRandomPlaylist(false) // No random selection
->setIgnoreErrors(true); // Continue on errors
Custom FFmpeg configurations:
$options = new ConverterOptions();
$options
->setAudioCodec('libmp3lame') // Specific codec
->setBitrate('320k') // Bitrate
->setSampleRate(44100) // Sample rate
->setChannels(2) // Stereo
->setVolumeBoost(1.5) // Volume multiplier
->setNormalizeAudio(true); // Normalize volume