mirror of
https://github.com/immich-app/immich.git
synced 2025-08-05 08:42:27 -04:00
Merge branch 'immich-app:main' into rknn-toolkit2
This commit is contained in:
commit
b6c4b37237
@ -28,6 +28,7 @@ linter:
|
||||
use_build_context_synchronously: false
|
||||
require_trailing_commas: true
|
||||
unrelated_type_equality_checks: true
|
||||
prefer_const_constructors: true
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
|
@ -154,6 +154,9 @@
|
||||
"change_password_form_new_password": "New Password",
|
||||
"change_password_form_password_mismatch": "Passwords do not match",
|
||||
"change_password_form_reenter_new_password": "Re-enter New Password",
|
||||
"check_corrupt_asset_backup": "Check for corrupt asset backups",
|
||||
"check_corrupt_asset_backup_description": "Run this check only over Wi-Fi and once all assets have been backed-up. The procedure might take a few minutes.",
|
||||
"check_corrupt_asset_backup_button": "Perform check",
|
||||
"client_cert_dialog_msg_confirm": "OK",
|
||||
"client_cert_enter_password": "Enter Password",
|
||||
"client_cert_import": "Import",
|
||||
|
@ -78,7 +78,7 @@ class AlbumsPage extends HookConsumerWidget {
|
||||
showUploadButton: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
icon: const Icon(
|
||||
Icons.add_rounded,
|
||||
size: 28,
|
||||
),
|
||||
@ -112,13 +112,13 @@ class AlbumsPage extends HookConsumerWidget {
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
transform: GradientRotation(0.5 * pi),
|
||||
transform: const GradientRotation(0.5 * pi),
|
||||
),
|
||||
),
|
||||
child: TextField(
|
||||
autofocus: false,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.all(16),
|
||||
contentPadding: const EdgeInsets.all(16),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
borderSide: BorderSide(
|
||||
@ -362,13 +362,13 @@ class SortButton extends ConsumerWidget {
|
||||
|
||||
return MenuAnchor(
|
||||
style: MenuStyle(
|
||||
elevation: WidgetStatePropertyAll(1),
|
||||
elevation: const WidgetStatePropertyAll(1),
|
||||
shape: WidgetStateProperty.all(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
),
|
||||
padding: WidgetStatePropertyAll(
|
||||
padding: const WidgetStatePropertyAll(
|
||||
EdgeInsets.all(4),
|
||||
),
|
||||
),
|
||||
|
@ -49,7 +49,7 @@ class AlbumOptionsPage extends HookConsumerWidget {
|
||||
|
||||
if (isSuccess) {
|
||||
context.navigateTo(
|
||||
TabControllerRoute(children: [AlbumsRoute()]),
|
||||
const TabControllerRoute(children: [AlbumsRoute()]),
|
||||
);
|
||||
} else {
|
||||
showErrorMessage();
|
||||
|
@ -33,7 +33,7 @@ class AlbumSharedUserSelectionPage extends HookConsumerWidget {
|
||||
if (newAlbum != null) {
|
||||
ref.watch(albumTitleProvider.notifier).clearAlbumTitle();
|
||||
context.maybePop(true);
|
||||
context.navigateTo(TabControllerRoute(children: [AlbumsRoute()]));
|
||||
context.navigateTo(const TabControllerRoute(children: [AlbumsRoute()]));
|
||||
}
|
||||
|
||||
ScaffoldMessenger(
|
||||
|
@ -28,7 +28,7 @@ class LibraryPage extends ConsumerWidget {
|
||||
ref.watch(serverInfoProvider.select((v) => v.serverFeatures.trash));
|
||||
|
||||
return Scaffold(
|
||||
appBar: ImmichAppBar(),
|
||||
appBar: const ImmichAppBar(),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: ListView(
|
||||
@ -81,7 +81,7 @@ class LibraryPage extends ConsumerWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
QuickAccessButtons(),
|
||||
const QuickAccessButtons(),
|
||||
const SizedBox(
|
||||
height: 32,
|
||||
),
|
||||
@ -122,8 +122,8 @@ class QuickAccessButtons extends ConsumerWidget {
|
||||
ListTile(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(20),
|
||||
topRight: Radius.circular(20),
|
||||
topLeft: const Radius.circular(20),
|
||||
topRight: const Radius.circular(20),
|
||||
bottomLeft: Radius.circular(partners.isEmpty ? 20 : 0),
|
||||
bottomRight: Radius.circular(partners.isEmpty ? 20 : 0),
|
||||
),
|
||||
@ -173,7 +173,7 @@ class PartnerList extends ConsumerWidget {
|
||||
right: 18.0,
|
||||
),
|
||||
leading: userAvatar(context, partner, radius: 16),
|
||||
title: Text(
|
||||
title: const Text(
|
||||
"partner_list_user_photos",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
|
@ -60,7 +60,7 @@ class PlacesCollectionPage extends HookConsumerWidget {
|
||||
);
|
||||
},
|
||||
error: (error, stask) => const Text('Error getting places'),
|
||||
loading: () => Center(child: const CircularProgressIndicator()),
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -499,8 +499,8 @@ class SearchPage extends HookConsumerWidget {
|
||||
controller: textSearchController,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: prefilter != null
|
||||
? EdgeInsets.only(left: 24)
|
||||
: EdgeInsets.all(8),
|
||||
? const EdgeInsets.only(left: 24)
|
||||
: const EdgeInsets.all(8),
|
||||
prefixIcon: prefilter != null
|
||||
? null
|
||||
: Icon(
|
||||
@ -647,7 +647,9 @@ class SearchResultGrid extends StatelessWidget {
|
||||
stackEnabled: false,
|
||||
emptyIndicator: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: !isSearching ? SearchEmptyContent() : SizedBox.shrink(),
|
||||
child: !isSearching
|
||||
? const SearchEmptyContent()
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -666,7 +668,7 @@ class SearchEmptyContent extends StatelessWidget {
|
||||
child: ListView(
|
||||
shrinkWrap: false,
|
||||
children: [
|
||||
SizedBox(height: 40),
|
||||
const SizedBox(height: 40),
|
||||
Center(
|
||||
child: Image.asset(
|
||||
context.isDarkTheme
|
||||
@ -675,15 +677,15 @@ class SearchEmptyContent extends StatelessWidget {
|
||||
height: 125,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
const SizedBox(height: 16),
|
||||
Center(
|
||||
child: Text(
|
||||
"Search for your photos and videos",
|
||||
style: context.textTheme.labelLarge,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 32),
|
||||
QuickLinkList(),
|
||||
const SizedBox(height: 32),
|
||||
const QuickLinkList(),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -725,13 +727,13 @@ class QuickLinkList extends StatelessWidget {
|
||||
QuickLink(
|
||||
title: 'videos'.tr(),
|
||||
icon: Icons.play_circle_outline_rounded,
|
||||
onTap: () => context.pushRoute(AllVideosRoute()),
|
||||
onTap: () => context.pushRoute(const AllVideosRoute()),
|
||||
),
|
||||
QuickLink(
|
||||
title: 'favorites'.tr(),
|
||||
icon: Icons.favorite_border_rounded,
|
||||
isBottom: true,
|
||||
onTap: () => context.pushRoute(FavoritesRoute()),
|
||||
onTap: () => context.pushRoute(const FavoritesRoute()),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -39,7 +39,9 @@ class AuthApiRepository extends ApiRepository implements IAuthApiRepository {
|
||||
|
||||
@override
|
||||
Future<void> logout() async {
|
||||
await _apiService.authenticationApi.logout().timeout(Duration(seconds: 7));
|
||||
await _apiService.authenticationApi
|
||||
.logout()
|
||||
.timeout(const Duration(seconds: 7));
|
||||
}
|
||||
|
||||
_mapLoginReponse(LoginResponseDto dto) {
|
||||
|
@ -104,7 +104,7 @@ class ApiService implements Authentication {
|
||||
|
||||
try {
|
||||
await setEndpoint(serverUrl);
|
||||
await serverInfoApi.pingServer().timeout(Duration(seconds: 5));
|
||||
await serverInfoApi.pingServer().timeout(const Duration(seconds: 5));
|
||||
} on TimeoutException catch (_) {
|
||||
return false;
|
||||
} on SocketException catch (_) {
|
||||
|
@ -198,7 +198,7 @@ ThemeData getThemeData({
|
||||
scrolledUnderElevation: 0,
|
||||
centerTitle: true,
|
||||
),
|
||||
textTheme: TextTheme(
|
||||
textTheme: const TextTheme(
|
||||
displayLarge: TextStyle(
|
||||
fontSize: 26,
|
||||
fontWeight: FontWeight.bold,
|
||||
@ -211,15 +211,15 @@ ThemeData getThemeData({
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
titleSmall: const TextStyle(
|
||||
titleSmall: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
titleMedium: const TextStyle(
|
||||
titleMedium: TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
titleLarge: const TextStyle(
|
||||
titleLarge: TextStyle(
|
||||
fontSize: 26.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
|
@ -46,7 +46,7 @@ class AlbumViewerAppbar extends HookConsumerWidget
|
||||
final bool success;
|
||||
if (album.shared) {
|
||||
success = await ref.watch(albumProvider.notifier).deleteAlbum(album);
|
||||
context.navigateTo(TabControllerRoute(children: [AlbumsRoute()]));
|
||||
context.navigateTo(const TabControllerRoute(children: [AlbumsRoute()]));
|
||||
} else {
|
||||
success = await ref.watch(albumProvider.notifier).deleteAlbum(album);
|
||||
context
|
||||
@ -113,7 +113,7 @@ class AlbumViewerAppbar extends HookConsumerWidget
|
||||
await ref.watch(albumProvider.notifier).leaveAlbum(album);
|
||||
|
||||
if (isSuccess) {
|
||||
context.navigateTo(TabControllerRoute(children: [AlbumsRoute()]));
|
||||
context.navigateTo(const TabControllerRoute(children: [AlbumsRoute()]));
|
||||
} else {
|
||||
context.pop();
|
||||
ImmichToast.show(
|
||||
|
@ -338,7 +338,7 @@ class BottomGalleryBar extends ConsumerWidget {
|
||||
),
|
||||
position: DecorationPosition.background,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 40.0),
|
||||
padding: const EdgeInsets.only(top: 40.0),
|
||||
child: Column(
|
||||
children: [
|
||||
if (showVideoPlayerControls) const VideoControls(),
|
||||
|
@ -143,9 +143,9 @@ class ImmichAppBarDialog extends HookConsumerWidget {
|
||||
);
|
||||
},
|
||||
trailing: isLoggingOut.value
|
||||
? SizedBox.square(
|
||||
? const SizedBox.square(
|
||||
dimension: 20,
|
||||
child: const CircularProgressIndicator(strokeWidth: 2),
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
|
@ -54,7 +54,7 @@ class BackupSettings extends HookConsumerWidget {
|
||||
if (Platform.isAndroid && isAdvancedTroubleshooting.value)
|
||||
SettingsButtonListTile(
|
||||
icon: Icons.warning_rounded,
|
||||
title: 'Check for corrupt asset backups',
|
||||
title: 'check_corrupt_asset_backup'.tr(),
|
||||
subtitle: isCorruptCheckInProgress
|
||||
? const Column(
|
||||
children: [
|
||||
@ -65,9 +65,9 @@ class BackupSettings extends HookConsumerWidget {
|
||||
)
|
||||
: null,
|
||||
subtileText: !isCorruptCheckInProgress
|
||||
? 'Run this check only over Wi-Fi and once all assets have been backed-up. The procedure might take a few minutes.'
|
||||
? 'check_corrupt_asset_backup_description'.tr()
|
||||
: null,
|
||||
buttonText: 'Perform check',
|
||||
buttonText: 'check_corrupt_asset_backup_button'.tr(),
|
||||
onButtonTap: !isCorruptCheckInProgress
|
||||
? () => ref
|
||||
.read(backupVerificationProvider.notifier)
|
||||
|
@ -27,7 +27,7 @@ void main() {
|
||||
mapStateNotifier = MockMapStateNotifier(mapState);
|
||||
overrides = [
|
||||
mapStateNotifierProvider.overrideWith(() => mapStateNotifier),
|
||||
localeProvider.overrideWithValue(Locale("en")),
|
||||
localeProvider.overrideWithValue(const Locale("en")),
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -571,6 +571,7 @@ describe(AssetMediaService.name, () => {
|
||||
path: '/path/to/preview.jpg',
|
||||
cacheControl: CacheControl.PRIVATE_WITH_CACHE,
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'asset-id_thumbnail.jpg',
|
||||
}),
|
||||
);
|
||||
});
|
||||
@ -585,6 +586,7 @@ describe(AssetMediaService.name, () => {
|
||||
path: assetStub.image.files[0].path,
|
||||
cacheControl: CacheControl.PRIVATE_WITH_CACHE,
|
||||
contentType: 'image/jpeg',
|
||||
fileName: 'asset-id_preview.jpg',
|
||||
}),
|
||||
);
|
||||
});
|
||||
@ -599,6 +601,7 @@ describe(AssetMediaService.name, () => {
|
||||
path: assetStub.image.files[1].path,
|
||||
cacheControl: CacheControl.PRIVATE_WITH_CACHE,
|
||||
contentType: 'application/octet-stream',
|
||||
fileName: 'asset-id_thumbnail.ext',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ import { AuthRequest } from 'src/middleware/auth.guard';
|
||||
import { BaseService } from 'src/services/base.service';
|
||||
import { requireUploadAccess } from 'src/utils/access';
|
||||
import { asRequest, getAssetFiles, onBeforeLink } from 'src/utils/asset.util';
|
||||
import { ImmichFileResponse } from 'src/utils/file';
|
||||
import { getFilenameExtension, getFileNameWithoutExtension, ImmichFileResponse } from 'src/utils/file';
|
||||
import { mimeTypes } from 'src/utils/mime-types';
|
||||
import { fromChecksum } from 'src/utils/request';
|
||||
import { QueryFailedError } from 'typeorm';
|
||||
@ -217,8 +217,12 @@ export class AssetMediaService extends BaseService {
|
||||
if (!filepath) {
|
||||
throw new NotFoundException('Asset media not found');
|
||||
}
|
||||
let fileName = getFileNameWithoutExtension(asset.originalFileName);
|
||||
fileName += `_${size}`;
|
||||
fileName += getFilenameExtension(filepath);
|
||||
|
||||
return new ImmichFileResponse({
|
||||
fileName,
|
||||
path: filepath,
|
||||
contentType: mimeTypes.lookup(filepath),
|
||||
cacheControl: CacheControl.PRIVATE_WITH_CACHE,
|
||||
|
@ -1637,7 +1637,10 @@ describe(MediaService.name, () => {
|
||||
'/original/path.ext',
|
||||
'upload/encoded-video/user-id/as/se/asset-id.mp4',
|
||||
expect.objectContaining({
|
||||
inputOptions: expect.arrayContaining(['-init_hw_device qsv=hw', '-filter_hw_device hw']),
|
||||
inputOptions: expect.arrayContaining([
|
||||
'-init_hw_device qsv=hw,child_device=/dev/dri/renderD128',
|
||||
'-filter_hw_device hw',
|
||||
]),
|
||||
outputOptions: expect.arrayContaining([
|
||||
`-c:v h264_qsv`,
|
||||
'-c:a copy',
|
||||
@ -1696,7 +1699,10 @@ describe(MediaService.name, () => {
|
||||
'/original/path.ext',
|
||||
'upload/encoded-video/user-id/as/se/asset-id.mp4',
|
||||
expect.objectContaining({
|
||||
inputOptions: expect.arrayContaining(['-init_hw_device qsv=hw', '-filter_hw_device hw']),
|
||||
inputOptions: expect.arrayContaining([
|
||||
'-init_hw_device qsv=hw,child_device=/dev/dri/renderD128',
|
||||
'-filter_hw_device hw',
|
||||
]),
|
||||
outputOptions: expect.not.arrayContaining([expect.stringContaining('-preset')]),
|
||||
twoPass: false,
|
||||
}),
|
||||
@ -1713,7 +1719,10 @@ describe(MediaService.name, () => {
|
||||
'/original/path.ext',
|
||||
'upload/encoded-video/user-id/as/se/asset-id.mp4',
|
||||
expect.objectContaining({
|
||||
inputOptions: expect.arrayContaining(['-init_hw_device qsv=hw', '-filter_hw_device hw']),
|
||||
inputOptions: expect.arrayContaining([
|
||||
'-init_hw_device qsv=hw,child_device=/dev/dri/renderD128',
|
||||
'-filter_hw_device hw',
|
||||
]),
|
||||
outputOptions: expect.arrayContaining(['-low_power 1']),
|
||||
twoPass: false,
|
||||
}),
|
||||
@ -1730,6 +1739,26 @@ describe(MediaService.name, () => {
|
||||
expect(loggerMock.debug).toHaveBeenCalledWith('No devices found in /dev/dri.');
|
||||
});
|
||||
|
||||
it('should prefer higher index renderD* device for qsv', async () => {
|
||||
storageMock.readdir.mockResolvedValue(['card1', 'renderD129', 'card0', 'renderD128']);
|
||||
mediaMock.probe.mockResolvedValue(probeStub.matroskaContainer);
|
||||
systemMock.get.mockResolvedValue({ ffmpeg: { accel: TranscodeHWAccel.QSV } });
|
||||
assetMock.getByIds.mockResolvedValue([assetStub.video]);
|
||||
await sut.handleVideoConversion({ id: assetStub.video.id });
|
||||
expect(mediaMock.transcode).toHaveBeenCalledWith(
|
||||
'/original/path.ext',
|
||||
'upload/encoded-video/user-id/as/se/asset-id.mp4',
|
||||
expect.objectContaining({
|
||||
inputOptions: expect.arrayContaining([
|
||||
'-init_hw_device qsv=hw,child_device=/dev/dri/renderD129',
|
||||
'-filter_hw_device hw',
|
||||
]),
|
||||
outputOptions: expect.arrayContaining([`-c:v h264_qsv`]),
|
||||
twoPass: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should use hardware decoding for qsv if enabled', async () => {
|
||||
storageMock.readdir.mockResolvedValue(['renderD128']);
|
||||
mediaMock.probe.mockResolvedValue(probeStub.matroskaContainer);
|
||||
@ -1750,6 +1779,7 @@ describe(MediaService.name, () => {
|
||||
'-async_depth 4',
|
||||
'-noautorotate',
|
||||
'-threads 1',
|
||||
'-qsv_device /dev/dri/renderD128',
|
||||
]),
|
||||
outputOptions: expect.arrayContaining([
|
||||
expect.stringContaining('scale_qsv=-1:720:async_depth=4:mode=hq:format=nv12'),
|
||||
@ -1939,8 +1969,8 @@ describe(MediaService.name, () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should prefer gpu for vaapi if available', async () => {
|
||||
storageMock.readdir.mockResolvedValue(['renderD129', 'card1', 'card0', 'renderD128']);
|
||||
it('should prefer higher index renderD* device for vaapi', async () => {
|
||||
storageMock.readdir.mockResolvedValue(['card1', 'renderD129', 'card0', 'renderD128']);
|
||||
mediaMock.probe.mockResolvedValue(probeStub.matroskaContainer);
|
||||
systemMock.get.mockResolvedValue({ ffmpeg: { accel: TranscodeHWAccel.VAAPI } });
|
||||
assetMock.getByIds.mockResolvedValue([assetStub.video]);
|
||||
@ -1950,27 +1980,7 @@ describe(MediaService.name, () => {
|
||||
'upload/encoded-video/user-id/as/se/asset-id.mp4',
|
||||
expect.objectContaining({
|
||||
inputOptions: expect.arrayContaining([
|
||||
'-init_hw_device vaapi=accel:/dev/dri/card1',
|
||||
'-filter_hw_device accel',
|
||||
]),
|
||||
outputOptions: expect.arrayContaining([`-c:v h264_vaapi`]),
|
||||
twoPass: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should prefer higher index gpu node', async () => {
|
||||
storageMock.readdir.mockResolvedValue(['renderD129', 'renderD130', 'renderD128']);
|
||||
mediaMock.probe.mockResolvedValue(probeStub.matroskaContainer);
|
||||
systemMock.get.mockResolvedValue({ ffmpeg: { accel: TranscodeHWAccel.VAAPI } });
|
||||
assetMock.getByIds.mockResolvedValue([assetStub.video]);
|
||||
await sut.handleVideoConversion({ id: assetStub.video.id });
|
||||
expect(mediaMock.transcode).toHaveBeenCalledWith(
|
||||
'/original/path.ext',
|
||||
'upload/encoded-video/user-id/as/se/asset-id.mp4',
|
||||
expect.objectContaining({
|
||||
inputOptions: expect.arrayContaining([
|
||||
'-init_hw_device vaapi=accel:/dev/dri/renderD130',
|
||||
'-init_hw_device vaapi=accel:/dev/dri/renderD129',
|
||||
'-filter_hw_device accel',
|
||||
]),
|
||||
outputOptions: expect.arrayContaining([`-c:v h264_vaapi`]),
|
||||
@ -2020,6 +2030,7 @@ describe(MediaService.name, () => {
|
||||
'-hwaccel_output_format vaapi',
|
||||
'-noautorotate',
|
||||
'-threads 1',
|
||||
'-hwaccel_device /dev/dri/renderD128',
|
||||
]),
|
||||
outputOptions: expect.arrayContaining([
|
||||
expect.stringContaining('scale_vaapi=-2:720:mode=hq:out_range=pc:format=nv12'),
|
||||
|
@ -24,6 +24,7 @@ export class ImmichFileResponse {
|
||||
public readonly path!: string;
|
||||
public readonly contentType!: string;
|
||||
public readonly cacheControl!: CacheControl;
|
||||
public readonly fileName?: string;
|
||||
|
||||
constructor(response: ImmichFileResponse) {
|
||||
Object.assign(this, response);
|
||||
@ -56,6 +57,9 @@ export const sendFile = async (
|
||||
}
|
||||
|
||||
res.header('Content-Type', file.contentType);
|
||||
if (file.fileName) {
|
||||
res.header('Content-Disposition', `inline; filename="${file.fileName}"`);
|
||||
}
|
||||
|
||||
const options: SendFileOptions = { dotfiles: 'allow' };
|
||||
if (!isAbsolute(file.path)) {
|
||||
|
@ -322,14 +322,14 @@ export class BaseConfig implements VideoCodecSWConfig {
|
||||
}
|
||||
|
||||
export class BaseHWConfig extends BaseConfig implements VideoCodecHWConfig {
|
||||
protected devices: string[];
|
||||
protected device: string;
|
||||
|
||||
constructor(
|
||||
protected config: SystemConfigFFmpegDto,
|
||||
devices: string[] = [],
|
||||
) {
|
||||
super(config);
|
||||
this.devices = this.validateDevices(devices);
|
||||
this.device = this.getDevice(devices);
|
||||
}
|
||||
|
||||
getSupportedCodecs() {
|
||||
@ -337,20 +337,31 @@ export class BaseHWConfig extends BaseConfig implements VideoCodecHWConfig {
|
||||
}
|
||||
|
||||
validateDevices(devices: string[]) {
|
||||
return devices
|
||||
.filter((device) => device.startsWith('renderD') || device.startsWith('card'))
|
||||
.sort((a, b) => {
|
||||
// order GPU devices first
|
||||
if (a.startsWith('card') && b.startsWith('renderD')) {
|
||||
return -1;
|
||||
if (devices.length === 0) {
|
||||
throw new Error('No /dev/dri devices found. If using Docker, make sure at least one /dev/dri device is mounted');
|
||||
}
|
||||
if (a.startsWith('renderD') && b.startsWith('card')) {
|
||||
return 1;
|
||||
}
|
||||
return -a.localeCompare(b);
|
||||
|
||||
return devices.filter(function (device) {
|
||||
return device.startsWith('renderD') || device.startsWith('card');
|
||||
});
|
||||
}
|
||||
|
||||
getDevice(devices: string[]) {
|
||||
if (this.config.preferredHwDevice === 'auto') {
|
||||
// eslint-disable-next-line unicorn/no-array-reduce
|
||||
return `/dev/dri/${this.validateDevices(devices).reduce(function (a, b) {
|
||||
return a.localeCompare(b) < 0 ? b : a;
|
||||
})}`;
|
||||
}
|
||||
|
||||
const deviceName = this.config.preferredHwDevice.replace('/dev/dri/', '');
|
||||
if (!devices.includes(deviceName)) {
|
||||
throw new Error(`Device '${deviceName}' does not exist. If using Docker, make sure this device is mounted`);
|
||||
}
|
||||
|
||||
return `/dev/dri/${deviceName}`;
|
||||
}
|
||||
|
||||
getVideoCodec(): string {
|
||||
return `${this.config.targetVideoCodec}_${this.config.accel}`;
|
||||
}
|
||||
@ -361,20 +372,6 @@ export class BaseHWConfig extends BaseConfig implements VideoCodecHWConfig {
|
||||
}
|
||||
return this.config.gopSize;
|
||||
}
|
||||
|
||||
getPreferredHardwareDevice(): string | undefined {
|
||||
const device = this.config.preferredHwDevice;
|
||||
if (device === 'auto') {
|
||||
return;
|
||||
}
|
||||
|
||||
const deviceName = device.replace('/dev/dri/', '');
|
||||
if (!this.devices.includes(deviceName)) {
|
||||
throw new Error(`Device '${device}' does not exist`);
|
||||
}
|
||||
|
||||
return `/dev/dri/${deviceName}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class ThumbnailConfig extends BaseConfig {
|
||||
@ -513,12 +510,16 @@ export class AV1Config extends BaseConfig {
|
||||
}
|
||||
|
||||
export class NvencSwDecodeConfig extends BaseHWConfig {
|
||||
getDevice() {
|
||||
return '0';
|
||||
}
|
||||
|
||||
getSupportedCodecs() {
|
||||
return [VideoCodec.H264, VideoCodec.HEVC, VideoCodec.AV1];
|
||||
}
|
||||
|
||||
getBaseInputOptions() {
|
||||
return ['-init_hw_device cuda=cuda:0', '-filter_hw_device cuda'];
|
||||
return [`-init_hw_device cuda=cuda:${this.device}`, '-filter_hw_device cuda'];
|
||||
}
|
||||
|
||||
getBaseOutputOptions(target: TranscodeTarget, videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) {
|
||||
@ -641,17 +642,7 @@ export class NvencHwDecodeConfig extends NvencSwDecodeConfig {
|
||||
|
||||
export class QsvSwDecodeConfig extends BaseHWConfig {
|
||||
getBaseInputOptions() {
|
||||
if (this.devices.length === 0) {
|
||||
throw new Error('No QSV device found');
|
||||
}
|
||||
|
||||
let qsvString = '';
|
||||
const hwDevice = this.getPreferredHardwareDevice();
|
||||
if (hwDevice) {
|
||||
qsvString = `,child_device=${hwDevice}`;
|
||||
}
|
||||
|
||||
return [`-init_hw_device qsv=hw${qsvString}`, '-filter_hw_device hw'];
|
||||
return [`-init_hw_device qsv=hw,child_device=${this.device}`, '-filter_hw_device hw'];
|
||||
}
|
||||
|
||||
getBaseOutputOptions(target: TranscodeTarget, videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) {
|
||||
@ -721,23 +712,14 @@ export class QsvSwDecodeConfig extends BaseHWConfig {
|
||||
|
||||
export class QsvHwDecodeConfig extends QsvSwDecodeConfig {
|
||||
getBaseInputOptions() {
|
||||
if (this.devices.length === 0) {
|
||||
throw new Error('No QSV device found');
|
||||
}
|
||||
|
||||
const options = [
|
||||
return [
|
||||
'-hwaccel qsv',
|
||||
'-hwaccel_output_format qsv',
|
||||
'-async_depth 4',
|
||||
'-noautorotate',
|
||||
`-qsv_device ${this.device}`,
|
||||
...this.getInputThreadOptions(),
|
||||
];
|
||||
const hwDevice = this.getPreferredHardwareDevice();
|
||||
if (hwDevice) {
|
||||
options.push(`-qsv_device ${hwDevice}`);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
getFilterOptions(videoStream: VideoStreamInfo) {
|
||||
@ -789,16 +771,7 @@ export class QsvHwDecodeConfig extends QsvSwDecodeConfig {
|
||||
|
||||
export class VaapiSwDecodeConfig extends BaseHWConfig {
|
||||
getBaseInputOptions() {
|
||||
if (this.devices.length === 0) {
|
||||
throw new Error('No VAAPI device found');
|
||||
}
|
||||
|
||||
let hwDevice = this.getPreferredHardwareDevice();
|
||||
if (!hwDevice) {
|
||||
hwDevice = `/dev/dri/${this.devices[0]}`;
|
||||
}
|
||||
|
||||
return [`-init_hw_device vaapi=accel:${hwDevice}`, '-filter_hw_device accel'];
|
||||
return [`-init_hw_device vaapi=accel:${this.device}`, '-filter_hw_device accel'];
|
||||
}
|
||||
|
||||
getFilterOptions(videoStream: VideoStreamInfo) {
|
||||
@ -856,22 +829,13 @@ export class VaapiSwDecodeConfig extends BaseHWConfig {
|
||||
|
||||
export class VaapiHwDecodeConfig extends VaapiSwDecodeConfig {
|
||||
getBaseInputOptions() {
|
||||
if (this.devices.length === 0) {
|
||||
throw new Error('No VAAPI device found');
|
||||
}
|
||||
|
||||
const options = [
|
||||
return [
|
||||
'-hwaccel vaapi',
|
||||
'-hwaccel_output_format vaapi',
|
||||
'-noautorotate',
|
||||
`-hwaccel_device ${this.device}`,
|
||||
...this.getInputThreadOptions(),
|
||||
];
|
||||
const hwDevice = this.getPreferredHardwareDevice();
|
||||
if (hwDevice) {
|
||||
options.push(`-hwaccel_device ${hwDevice}`);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
getFilterOptions(videoStream: VideoStreamInfo) {
|
||||
@ -934,9 +898,6 @@ export class RkmppSwDecodeConfig extends BaseHWConfig {
|
||||
}
|
||||
|
||||
getBaseInputOptions(): string[] {
|
||||
if (this.devices.length === 0) {
|
||||
throw new Error('No RKMPP device found');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -987,10 +948,6 @@ export class RkmppHwDecodeConfig extends RkmppSwDecodeConfig {
|
||||
}
|
||||
|
||||
getBaseInputOptions() {
|
||||
if (this.devices.length === 0) {
|
||||
throw new Error('No RKMPP device found');
|
||||
}
|
||||
|
||||
return ['-hwaccel rkmpp', '-hwaccel_output_format drm_prime', '-afbc rga', '-noautorotate'];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user