[windows] ffmpeg install windows

This commit is contained in:
jscampucci 2024-08-06 10:03:58 +02:00
parent 9e18a522f1
commit 01db0170fd
3 changed files with 24 additions and 22 deletions

4
.gitignore vendored
View File

@ -47,4 +47,6 @@ app.*.map.json
/android/app/release
samples/
apps_logs.txt
apps_logs.txt
windows/out/build/
.vs/

Binary file not shown.

View File

@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:get/get_navigation/src/nav2/get_router_delegate.dart';
import 'package:logger/logger.dart';
import 'package:path/path.dart';
import 'package:notube/constants.dart';
import 'package:notube/models/video.dart';
import 'package:notube/services/file_logger.dart';
@ -38,6 +39,7 @@ class DLServices {
Future<void> _init() async {
tempDir = await getTemporaryDirectory();
if (Platform.isWindows) {
checkFFmpeg();
assetName = 'yt-dlp.exe';
} else if (Platform.isLinux) {
checkFFmpeg();
@ -68,9 +70,7 @@ class DLServices {
}
var shell = Shell();
await shell.run(
'$ytDlpPath -U'
);
await shell.run('$ytDlpPath -U');
// await Process.run(ytDlpPath, ['-U'])
}
@ -93,52 +93,52 @@ class DLServices {
) {
completer.completeError(error);
});
} catch(error) {
} catch (error) {
completer.completeError(error);
}
}
Future<void> checkFFmpeg() async {
var result = await futureShell('ffmpeg -version');
debugPrint('$result');
/*
try {
var result = await Process.run('ffmpeg', ['-version']);
if (result.exitCode == 0) {
print('FFmpeg is already installed.');
return;
}
debugPrint('RESULTS: $result');
result = await Process.run('sudo', ['-n', 'true']);
bool hasSudo = result.exitCode == 0;
if (hasSudo) {
print('Installing FFmpeg...');
if (Platform.isLinux) {
print('Installing FFmpeg...');
if (Platform.isLinux) {
result = await Process.run('sudo', ['-n', 'true']);
bool hasSudo = result.exitCode == 0;
if (hasSudo) {
result =
await Process.run('sudo', ['apt-get', 'install', 'ffmpeg', '-y']);
} else if (Platform.isMacOS) {
result = await Process.run('brew', ['install', 'ffmpeg']);
} else {
print('Cannot install FFmpeg without sudo privileges.');
}
if (result.exitCode == 0) {
print('FFmpeg installed successfully.');
} else {
print('Error installing FFmpeg: ${result.stderr}');
}
} else {
print('Cannot install FFmpeg without sudo privileges.');
// Here, you might want to inform the user they need to manually install FFmpeg
} else if (Platform.isMacOS) {
result = await Process.run('brew', ['install', 'ffmpeg']);
} else if (Platform.isWindows) {
Directory directory = await getApplicationDocumentsDirectory();
String assetsPath = join(directory.path, 'assets');
result = await Process.run('setx', [
'PATH',
'$assetsPath;%PATH%',
]);
}
} catch (e) {
print('An error occurred: $e');
}
*/
}
Future<Stream> downloadFile(Video video) async {