diff --git a/lib/services/ffmpeg_models.dart b/lib/services/ffmpeg_models.dart index 7d9a947d..d3dd13df 100644 --- a/lib/services/ffmpeg_models.dart +++ b/lib/services/ffmpeg_models.dart @@ -5,51 +5,25 @@ import 'package:ffmpeg_kit_flutter_new_full/ffmpeg_session.dart'; class DownloadDecryptionDescriptor { final String strategy; final String key; - final String? iv; final String? inputFormat; final String? outputExtension; - final Map options; const DownloadDecryptionDescriptor({ required this.strategy, required this.key, - this.iv, this.inputFormat, this.outputExtension, - this.options = const {}, }); factory DownloadDecryptionDescriptor.fromJson(Map json) { - final rawOptions = json['options']; return DownloadDecryptionDescriptor( strategy: (json['strategy'] as String? ?? '').trim(), key: (json['key'] as String? ?? '').trim(), - iv: (json['iv'] as String?)?.trim(), inputFormat: (json['input_format'] as String?)?.trim(), outputExtension: (json['output_extension'] as String?)?.trim(), - options: rawOptions is Map - ? Map.from(rawOptions) - : const {}, ); } - Map toJson() { - final json = {'strategy': strategy, 'key': key}; - if (iv != null && iv!.isNotEmpty) { - json['iv'] = iv; - } - if (inputFormat != null && inputFormat!.isNotEmpty) { - json['input_format'] = inputFormat; - } - if (outputExtension != null && outputExtension!.isNotEmpty) { - json['output_extension'] = outputExtension; - } - if (options.isNotEmpty) { - json['options'] = options; - } - return json; - } - static DownloadDecryptionDescriptor? fromDownloadResult( Map result, ) { diff --git a/lib/services/ffmpeg_service.dart b/lib/services/ffmpeg_service.dart index 78665f5c..9d36c73e 100644 --- a/lib/services/ffmpeg_service.dart +++ b/lib/services/ffmpeg_service.dart @@ -588,22 +588,6 @@ class FFmpegService { return null; } - static Future decryptAudioFile({ - required String inputPath, - required String decryptionKey, - bool deleteOriginal = true, - }) async { - return decryptWithDescriptor( - inputPath: inputPath, - descriptor: DownloadDecryptionDescriptor( - strategy: _genericMovKeyDecryptionStrategy, - key: decryptionKey, - inputFormat: 'mov', - ), - deleteOriginal: deleteOriginal, - ); - } - static Future decryptWithDescriptor({ required String inputPath, required DownloadDecryptionDescriptor descriptor, @@ -809,31 +793,6 @@ class FFmpegService { } } - static Future convertFlacToMp3( - String inputPath, { - String bitrate = '320k', - bool deleteOriginal = true, - }) async { - final outputPath = _buildOutputPath(inputPath, '.mp3'); - - final command = - '-v error -hide_banner -i "$inputPath" -codec:a libmp3lame -b:a $bitrate -map 0:a -map_metadata 0 -id3v2_version 3 "$outputPath" -y'; - - final result = await _execute(command); - - if (result.success) { - if (deleteOriginal) { - try { - await File(inputPath).delete(); - } catch (_) {} - } - return outputPath; - } - - _log.e('FLAC to MP3 conversion failed: ${result.output}'); - return null; - } - static bool isActiveLiveDecryptedUrl(String url) { final active = _activeLiveDecryptUrl; if (active == null || active.isEmpty) return false; @@ -1261,103 +1220,6 @@ class FFmpegService { return port; } - static Future convertFlacToOpus( - String inputPath, { - String bitrate = '128k', - bool deleteOriginal = true, - }) async { - final outputPath = _buildOutputPath(inputPath, '.opus'); - - final command = - '-v error -hide_banner -i "$inputPath" -codec:a libopus -b:a $bitrate -vbr on -compression_level 10 -map 0:a -map_metadata 0 "$outputPath" -y'; - - final result = await _execute(command); - - if (result.success) { - if (deleteOriginal) { - try { - await File(inputPath).delete(); - } catch (_) {} - } - return outputPath; - } - - _log.e('FLAC to Opus conversion failed: ${result.output}'); - return null; - } - - static Future convertFlacToLossy( - String inputPath, { - required String format, - String? bitrate, - bool deleteOriginal = true, - }) async { - String bitrateValue = '320k'; - if (bitrate != null && bitrate.contains('_')) { - final parts = bitrate.split('_'); - if (parts.length == 2) { - bitrateValue = '${parts[1]}k'; - } - } - - switch (format.toLowerCase()) { - case 'opus': - final opusBitrate = bitrate?.startsWith('opus_') == true - ? bitrateValue - : '128k'; - return convertFlacToOpus( - inputPath, - bitrate: opusBitrate, - deleteOriginal: deleteOriginal, - ); - case 'mp3': - default: - final mp3Bitrate = bitrate?.startsWith('mp3_') == true - ? bitrateValue - : '320k'; - return convertFlacToMp3( - inputPath, - bitrate: mp3Bitrate, - deleteOriginal: deleteOriginal, - ); - } - } - - static Future convertFlacToM4a( - String inputPath, { - String codec = 'aac', - String bitrate = '256k', - }) async { - final dir = File(inputPath).parent.path; - final baseName = inputPath - .split(Platform.pathSeparator) - .last - .replaceAll('.flac', ''); - final outputDir = '$dir${Platform.pathSeparator}M4A'; - - await Directory(outputDir).create(recursive: true); - - final outputPath = '$outputDir${Platform.pathSeparator}$baseName.m4a'; - - String command; - if (codec == 'alac') { - command = - '-v error -hide_banner -i "$inputPath" -codec:a alac -map 0:a -map_metadata 0 "$outputPath" -y'; - } else { - command = - '-v error -hide_banner -i "$inputPath" -codec:a aac -b:a $bitrate -map 0:a -map_metadata 0 "$outputPath" -y'; - } - - final result = await _execute(command); - - if (result.success) { - return outputPath; - } - - _log.e('FLAC to M4A conversion failed: ${result.output}'); - return null; - } - static Future isAvailable() async { try { final version = await FFmpegKitConfig.getFFmpegVersion(); @@ -1367,14 +1229,6 @@ class FFmpegService { } } - static Future getVersion() async { - try { - return await FFmpegKitConfig.getFFmpegVersion(); - } catch (e) { - return null; - } - } - /// Scan an audio file for EBU R128 loudness and compute ReplayGain values. /// /// Uses the FFmpeg `ebur128` audio filter to measure integrated loudness (LUFS) diff --git a/test/maintainability_contracts_test.dart b/test/maintainability_contracts_test.dart index bf82845d..7804f558 100644 --- a/test/maintainability_contracts_test.dart +++ b/test/maintainability_contracts_test.dart @@ -177,7 +177,6 @@ void main() { expect(structured!.normalizedStrategy, 'ffmpeg.mov_key'); expect(structured.normalizedOutputExtension, '.m4a'); expect(structured.key, 'secret'); - expect(structured.options['repair_ac4'], isTrue); expect(legacy!.inputFormat, 'mov'); expect(legacy.normalizedOutputExtension, '.flac'); });