mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
fix(player): disable audio normalization on missing audio input (#1865)
* fix(player): disable audio normalization on missing audio input * fix(player): skip normalization when local audio input is missing * fix `hasDashAudio` --------- Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -161,6 +161,7 @@ abstract final class DownloadHttp {
|
|||||||
dashDrmType: 0,
|
dashDrmType: 0,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
entry.hasDashAudio = true;
|
||||||
}
|
}
|
||||||
return Type2(
|
return Type2(
|
||||||
duration: dash.duration!,
|
duration: dash.duration!,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import 'package:get/route_manager.dart';
|
|||||||
|
|
||||||
class BiliDownloadEntryInfo with MultiSelectData {
|
class BiliDownloadEntryInfo with MultiSelectData {
|
||||||
int mediaType;
|
int mediaType;
|
||||||
final bool hasDashAudio;
|
bool hasDashAudio;
|
||||||
bool isCompleted;
|
bool isCompleted;
|
||||||
int totalBytes;
|
int totalBytes;
|
||||||
int downloadedBytes;
|
int downloadedBytes;
|
||||||
|
|||||||
@@ -687,6 +687,7 @@ class VideoDetailController extends GetxController
|
|||||||
dir: args['dirPath'],
|
dir: args['dirPath'],
|
||||||
typeTag: entry.typeTag!,
|
typeTag: entry.typeTag!,
|
||||||
isMp4: entry.mediaType == 1,
|
isMp4: entry.mediaType == 1,
|
||||||
|
hasDashAudio: entry.hasDashAudio,
|
||||||
)
|
)
|
||||||
: NetworkSource(
|
: NetworkSource(
|
||||||
videoSource: video ?? videoUrl!,
|
videoSource: video ?? videoUrl!,
|
||||||
|
|||||||
@@ -788,33 +788,32 @@ class PlPlayerController with BlockConfigMixin {
|
|||||||
extras['audio-files'] =
|
extras['audio-files'] =
|
||||||
'"${Platform.isWindows ? audio.replaceAll(';', r'\;') : audio.replaceAll(':', r'\:')}"';
|
'"${Platform.isWindows ? audio.replaceAll(';', r'\;') : audio.replaceAll(':', r'\:')}"';
|
||||||
}
|
}
|
||||||
}
|
if (kDebugMode || Platform.isAndroid) {
|
||||||
|
String audioNormalization = AudioNormalization.getParamFromConfig(
|
||||||
if (kDebugMode || Platform.isAndroid) {
|
Pref.audioNormalization,
|
||||||
String audioNormalization = AudioNormalization.getParamFromConfig(
|
|
||||||
Pref.audioNormalization,
|
|
||||||
);
|
|
||||||
if (volume != null && volume.isNotEmpty) {
|
|
||||||
audioNormalization = audioNormalization.replaceFirstMapped(
|
|
||||||
loudnormRegExp,
|
|
||||||
(i) =>
|
|
||||||
'loudnorm=${volume.format(
|
|
||||||
Map.fromEntries(
|
|
||||||
i.group(1)!.split(':').map((item) {
|
|
||||||
final parts = item.split('=');
|
|
||||||
return MapEntry(parts[0].toLowerCase(), num.parse(parts[1]));
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
)}',
|
|
||||||
);
|
);
|
||||||
} else {
|
if (volume != null && volume.isNotEmpty) {
|
||||||
audioNormalization = audioNormalization.replaceFirst(
|
audioNormalization = audioNormalization.replaceFirstMapped(
|
||||||
loudnormRegExp,
|
loudnormRegExp,
|
||||||
AudioNormalization.getParamFromConfig(Pref.fallbackNormalization),
|
(i) =>
|
||||||
);
|
'loudnorm=${volume.format(
|
||||||
}
|
Map.fromEntries(
|
||||||
if (audioNormalization.isNotEmpty) {
|
i.group(1)!.split(':').map((item) {
|
||||||
extras['lavfi-complex'] = '"[aid1] $audioNormalization [ao]"';
|
final parts = item.split('=');
|
||||||
|
return MapEntry(parts[0].toLowerCase(), num.parse(parts[1]));
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)}',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
audioNormalization = audioNormalization.replaceFirst(
|
||||||
|
loudnormRegExp,
|
||||||
|
AudioNormalization.getParamFromConfig(Pref.fallbackNormalization),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (audioNormalization.isNotEmpty) {
|
||||||
|
extras['lavfi-complex'] = '"[aid1] $audioNormalization [ao]"';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -840,21 +839,21 @@ class PlPlayerController with BlockConfigMixin {
|
|||||||
SmartDialog.showToast('视频源为空,请重新进入本页面');
|
SmartDialog.showToast('视频源为空,请重新进入本页面');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String? audioUri;
|
final Map<String, String> extras = {};
|
||||||
if (!isLive) {
|
String video = dataSource.videoSource;
|
||||||
if (dataSource.audioSource.isNullOrEmpty) {
|
if (dataSource.audioSource case final audio? when (audio.isNotEmpty)) {
|
||||||
SmartDialog.showToast('音频源为空');
|
if (onlyPlayAudio.value) {
|
||||||
|
video = audio;
|
||||||
} else {
|
} else {
|
||||||
audioUri = Platform.isWindows
|
extras['audio-files'] =
|
||||||
? dataSource.audioSource!.replaceAll(';', '\\;')
|
'"${Platform.isWindows ? audio.replaceAll(';', r'\;') : audio.replaceAll(':', r'\:')}"';
|
||||||
: dataSource.audioSource!.replaceAll(':', '\\:');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await _videoPlayerController!.open(
|
await _videoPlayerController!.open(
|
||||||
Media(
|
Media(
|
||||||
dataSource.videoSource,
|
video,
|
||||||
start: position,
|
start: position,
|
||||||
extras: audioUri == null ? null : {'audio-files': '"$audioUri"'},
|
extras: extras.isEmpty ? null : extras,
|
||||||
),
|
),
|
||||||
play: true,
|
play: true,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class FileSource extends DataSource {
|
|||||||
FileSource({
|
FileSource({
|
||||||
required this.dir,
|
required this.dir,
|
||||||
required this.isMp4,
|
required this.isMp4,
|
||||||
|
required bool hasDashAudio,
|
||||||
required String typeTag,
|
required String typeTag,
|
||||||
}) : super(
|
}) : super(
|
||||||
videoSource: path.join(
|
videoSource: path.join(
|
||||||
@@ -32,7 +33,7 @@ class FileSource extends DataSource {
|
|||||||
typeTag,
|
typeTag,
|
||||||
isMp4 ? PathUtils.videoNameType1 : PathUtils.videoNameType2,
|
isMp4 ? PathUtils.videoNameType1 : PathUtils.videoNameType2,
|
||||||
),
|
),
|
||||||
audioSource: isMp4
|
audioSource: isMp4 || !hasDashAudio
|
||||||
? null
|
? null
|
||||||
: path.join(dir, typeTag, PathUtils.audioNameType2),
|
: path.join(dir, typeTag, PathUtils.audioNameType2),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ class DownloadService extends GetxService {
|
|||||||
final currentTime = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
final currentTime = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||||
final entry = BiliDownloadEntryInfo(
|
final entry = BiliDownloadEntryInfo(
|
||||||
mediaType: 2,
|
mediaType: 2,
|
||||||
hasDashAudio: true,
|
hasDashAudio: false,
|
||||||
isCompleted: false,
|
isCompleted: false,
|
||||||
totalBytes: 0,
|
totalBytes: 0,
|
||||||
downloadedBytes: 0,
|
downloadedBytes: 0,
|
||||||
@@ -206,7 +206,7 @@ class DownloadService extends GetxService {
|
|||||||
);
|
);
|
||||||
final entry = BiliDownloadEntryInfo(
|
final entry = BiliDownloadEntryInfo(
|
||||||
mediaType: 2,
|
mediaType: 2,
|
||||||
hasDashAudio: true,
|
hasDashAudio: false,
|
||||||
isCompleted: false,
|
isCompleted: false,
|
||||||
totalBytes: 0,
|
totalBytes: 0,
|
||||||
downloadedBytes: 0,
|
downloadedBytes: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user