[windows] ffmpeg install windows
This commit is contained in:
parent
9e18a522f1
commit
01db0170fd
|
|
@ -47,4 +47,6 @@ app.*.map.json
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
|
||||||
samples/
|
samples/
|
||||||
apps_logs.txt
|
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:flutter/services.dart';
|
||||||
import 'package:get/get_navigation/src/nav2/get_router_delegate.dart';
|
import 'package:get/get_navigation/src/nav2/get_router_delegate.dart';
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
import 'package:notube/constants.dart';
|
import 'package:notube/constants.dart';
|
||||||
import 'package:notube/models/video.dart';
|
import 'package:notube/models/video.dart';
|
||||||
import 'package:notube/services/file_logger.dart';
|
import 'package:notube/services/file_logger.dart';
|
||||||
|
|
@ -38,6 +39,7 @@ class DLServices {
|
||||||
Future<void> _init() async {
|
Future<void> _init() async {
|
||||||
tempDir = await getTemporaryDirectory();
|
tempDir = await getTemporaryDirectory();
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
|
checkFFmpeg();
|
||||||
assetName = 'yt-dlp.exe';
|
assetName = 'yt-dlp.exe';
|
||||||
} else if (Platform.isLinux) {
|
} else if (Platform.isLinux) {
|
||||||
checkFFmpeg();
|
checkFFmpeg();
|
||||||
|
|
@ -68,9 +70,7 @@ class DLServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
var shell = Shell();
|
var shell = Shell();
|
||||||
await shell.run(
|
await shell.run('$ytDlpPath -U');
|
||||||
'$ytDlpPath -U'
|
|
||||||
);
|
|
||||||
// await Process.run(ytDlpPath, ['-U'])
|
// await Process.run(ytDlpPath, ['-U'])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,52 +93,52 @@ class DLServices {
|
||||||
) {
|
) {
|
||||||
completer.completeError(error);
|
completer.completeError(error);
|
||||||
});
|
});
|
||||||
} catch(error) {
|
} catch (error) {
|
||||||
completer.completeError(error);
|
completer.completeError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> checkFFmpeg() async {
|
Future<void> checkFFmpeg() async {
|
||||||
var result = await futureShell('ffmpeg -version');
|
var result = await futureShell('ffmpeg -version');
|
||||||
debugPrint('$result');
|
debugPrint('$result');
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var result = await Process.run('ffmpeg', ['-version']);
|
var result = await Process.run('ffmpeg', ['-version']);
|
||||||
if (result.exitCode == 0) {
|
if (result.exitCode == 0) {
|
||||||
print('FFmpeg is already installed.');
|
print('FFmpeg is already installed.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint('RESULTS: $result');
|
debugPrint('RESULTS: $result');
|
||||||
|
|
||||||
result = await Process.run('sudo', ['-n', 'true']);
|
print('Installing FFmpeg...');
|
||||||
bool hasSudo = result.exitCode == 0;
|
if (Platform.isLinux) {
|
||||||
|
result = await Process.run('sudo', ['-n', 'true']);
|
||||||
if (hasSudo) {
|
bool hasSudo = result.exitCode == 0;
|
||||||
print('Installing FFmpeg...');
|
if (hasSudo) {
|
||||||
if (Platform.isLinux) {
|
|
||||||
result =
|
result =
|
||||||
await Process.run('sudo', ['apt-get', 'install', 'ffmpeg', '-y']);
|
await Process.run('sudo', ['apt-get', 'install', 'ffmpeg', '-y']);
|
||||||
} else if (Platform.isMacOS) {
|
} else {
|
||||||
result = await Process.run('brew', ['install', 'ffmpeg']);
|
print('Cannot install FFmpeg without sudo privileges.');
|
||||||
}
|
}
|
||||||
if (result.exitCode == 0) {
|
if (result.exitCode == 0) {
|
||||||
print('FFmpeg installed successfully.');
|
print('FFmpeg installed successfully.');
|
||||||
} else {
|
} else {
|
||||||
print('Error installing FFmpeg: ${result.stderr}');
|
print('Error installing FFmpeg: ${result.stderr}');
|
||||||
}
|
}
|
||||||
} else {
|
} else if (Platform.isMacOS) {
|
||||||
print('Cannot install FFmpeg without sudo privileges.');
|
result = await Process.run('brew', ['install', 'ffmpeg']);
|
||||||
// Here, you might want to inform the user they need to manually 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) {
|
} catch (e) {
|
||||||
print('An error occurred: $e');
|
print('An error occurred: $e');
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Stream> downloadFile(Video video) async {
|
Future<Stream> downloadFile(Video video) async {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue