[windows] ffmpeg install windows
This commit is contained in:
parent
9e18a522f1
commit
01db0170fd
|
|
@ -48,3 +48,5 @@ app.*.map.json
|
|||
|
||||
samples/
|
||||
apps_logs.txt
|
||||
windows/out/build/
|
||||
.vs/
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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,20 +93,16 @@ 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.');
|
||||
|
|
@ -115,30 +111,34 @@ class DLServices {
|
|||
|
||||
debugPrint('RESULTS: $result');
|
||||
|
||||
result = await Process.run('sudo', ['-n', 'true']);
|
||||
bool hasSudo = result.exitCode == 0;
|
||||
|
||||
if (hasSudo) {
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue