feat: Install FFmpeg with NVIDIA NVENC/NVDEC support via apt-get instead of a static build.

This commit is contained in:
Michael committed 2026-01-03 10:26:17 +01:00
1 parent 33a331dce9
commit 71630d75e8
9 files changed
+135 -86

No files matched your search

+14 -8
View File
@@ -19,8 +19,9 @@ String _getFFmpegPath() {
if (Platform.isWindows) {
if (File('ffmpeg.exe').existsSync()) return 'ffmpeg.exe';
if (File('bin/ffmpeg.exe').existsSync()) return 'bin/ffmpeg.exe';
if (File('ffmpeg/bin/ffmpeg.exe').existsSync())
if (File('ffmpeg/bin/ffmpeg.exe').existsSync()) {
return 'ffmpeg/bin/ffmpeg.exe';
}
}
return 'ffmpeg'; // Default to PATH
}
@@ -41,7 +42,8 @@ void _logGpuStatus() {
print('[FFmpeg] NVIDIA GPU acceleration ENABLED (NVDEC/NVENC)');
} else {
print(
'[FFmpeg] Using CPU processing (set NVIDIA_GPU=true to enable GPU)');
'[FFmpeg] Using CPU processing (set NVIDIA_GPU=true to enable GPU)',
);
}
_gpuStatusLogged = true;
}
@@ -116,8 +118,9 @@ PlaylistConfig? _getCurrentPlaylist(Request request) {
// ==========================================
Handler createLiveStreamHandler(
Future<PlaylistConfig?> Function(Request) getPlaylist,
{bool Function()? isGpuEnabled}) {
Future<PlaylistConfig?> Function(Request) getPlaylist, {
bool Function()? isGpuEnabled,
}) {
final router = Router();
// Route: /api/live/{streamId} (Catch all pattern to debug)
@@ -291,16 +294,18 @@ Handler createLiveStreamHandler(
final _lastLogTime = <String, int>{};
Handler createVodStreamHandler(
Future<PlaylistConfig?> Function(Request) getPlaylist,
{bool Function()? isGpuEnabled}) {
Future<PlaylistConfig?> Function(Request) getPlaylist, {
bool Function()? isGpuEnabled,
}) {
final router = Router();
// Route: /api/vod/{streamId}/playlist.m3u8
router.get('/<streamId>/playlist.m3u8',
(Request request, String streamId) async {
final playlist = await getPlaylist(request);
if (playlist == null)
if (playlist == null) {
return Response.internalServerError(body: 'No playlist');
}
final streamDir = Directory('${_hlsTempDir.path}/$streamId');
@@ -514,7 +519,8 @@ Handler createVodStreamHandler(
if (!playlistFile.existsSync()) {
return Response.internalServerError(
body: 'Timeout waiting for transcoder');
body: 'Timeout waiting for transcoder',
);
}
return Response.ok(
+14 -7
View File
@@ -91,7 +91,8 @@ void main(List<String> args) async {
final user = req.context['user'] as User?;
if (user == null || !user.isAdmin) {
return Response.forbidden(
jsonEncode({'error': 'Admin access required'}));
jsonEncode({'error': 'Admin access required'}),
);
}
final result = await cleanupService.runCleanup();
@@ -173,13 +174,19 @@ void main(List<String> args) async {
// Create Streaming Router (Mount handlers on correct paths)
final streamingRouter = Router()
..mount(
'/api/live',
createLiveStreamHandler(getPlaylist,
isGpuEnabled: db.isNvidiaGpuEnabled))
'/api/live',
createLiveStreamHandler(
getPlaylist,
isGpuEnabled: db.isNvidiaGpuEnabled,
),
)
..mount(
'/api/vod',
createVodStreamHandler(getPlaylist,
isGpuEnabled: db.isNvidiaGpuEnabled));
'/api/vod',
createVodStreamHandler(
getPlaylist,
isGpuEnabled: db.isNvidiaGpuEnabled,
),
);
// Main handler with API proxy and NEW Streaming Handlers
final handler = Cascade()