yt_downloader 0.1.0
yt_downloader: ^0.1.0 copied to clipboard
Download YouTube videos with quality selection and automatic video+audio merging.
yt_downloader #
Download YouTube videos with quality selection and automatic video+audio merging.
Features #
- Fetch available download formats (video+audio, video-only, audio-only)
- Type-safe quality selection via
VideoQualityandAudioQualityenums - Download streams with real-time progress tracking
- Automatic video+audio merging using FFmpeg
- Supports video IDs and full YouTube URLs
Installation #
dependencies:
yt_downloader: ^0.1.0
Android #
Add ProGuard rules in android/app/proguard-rules.pro:
-keep class com.arthemica.ffmpegkit.** { *; }
-keep class com.antonkarpenko.ffmpegkit.FFmpegKitConfig {
native <methods>;
void log(long, int, byte[]);
void statistics(long, int, float, float, long , double, double, double);
int safOpen(int);
int safClose(int);
}
-keep class com.antonkarpenko.ffmpegkit.AbiDetect {
native <methods>;
}
Minimum SDK: 24
Usage #
import 'package:yt_downloader/yt_downloader.dart';
final yt = YtDownloader();
// Get video info (accepts ID or URL)
final info = await yt.getInfo('https://youtube.com/watch?v=dQw4w9WgXcQ');
print(info.title);
print('Formats: ${info.formats.videoWithAudio.length}');
// Download best quality
await info.download(
format: info.formats.best!,
outputPath: '/path/to/output.mp4',
onProgress: (progress) {
print('${(progress * 100).toInt()}%');
},
);
// Or pick a specific quality
final format = info.formats.forQuality(VideoQuality.q720p);
if (format != null) {
await info.download(
format: format,
outputPath: '/path/to/720p.mp4',
);
}
Format Types #
| Type | Description | Merge needed? |
|---|---|---|
videoWithAudio |
All qualities with audio | Auto (high quality = yes) |
videoOnly |
Video stream only | N/A |
audioOnly |
Audio stream only | N/A |
Quality Enums #
// Video
VideoQuality.q2160p // 4K
VideoQuality.q1440p // 2K
VideoQuality.q1080p // Full HD
VideoQuality.q720p // HD
VideoQuality.q480p // SD
VideoQuality.q360p
VideoQuality.q240p
VideoQuality.q144p
// Audio
AudioQuality.high // 256+ kbps
AudioQuality.medium // 128 kbps
AudioQuality.low // 50 kbps
License #
MIT