feat(server): transcode bitrate and thread settings (#2488)

* support for two-pass transcoding

* added max bitrate and thread to transcode api

* admin page setting desc+bitrate and thread options

* Update web/src/lib/components/admin-page/settings/setting-input-field.svelte

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>

* Update web/src/lib/components/admin-page/settings/setting-input-field.svelte

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>

* two-pass slider, `crf` and `threads` as numbers

* updated and added transcode tests

* refactored `getFfmpegOptions`

* default `threads`, `maxBitrate` now 0, more tests

* vp9 constant quality mode

* fixed nullable `crf` and `threads`

* fixed two-pass slider, added apiproperty

* optional `desc` for `SettingSelect`

* disable two-pass if settings are incompatible

* fixed test

* transcode interface

---------

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
This commit is contained in:
Mert
2023-05-22 14:07:43 -04:00
committed by GitHub
parent f1384fea58
commit e9722710ac
19 changed files with 498 additions and 46 deletions

View File

@@ -8,11 +8,14 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**crf** | **String** | |
**crf** | **int** | |
**threads** | **int** | |
**preset** | **String** | |
**targetVideoCodec** | **String** | |
**targetAudioCodec** | **String** | |
**targetResolution** | **String** | |
**maxBitrate** | **String** | |
**twoPass** | **bool** | |
**transcode** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -14,14 +14,19 @@ class SystemConfigFFmpegDto {
/// Returns a new [SystemConfigFFmpegDto] instance.
SystemConfigFFmpegDto({
required this.crf,
required this.threads,
required this.preset,
required this.targetVideoCodec,
required this.targetAudioCodec,
required this.targetResolution,
required this.maxBitrate,
required this.twoPass,
required this.transcode,
});
String crf;
int crf;
int threads;
String preset;
@@ -31,37 +36,50 @@ class SystemConfigFFmpegDto {
String targetResolution;
String maxBitrate;
bool twoPass;
SystemConfigFFmpegDtoTranscodeEnum transcode;
@override
bool operator ==(Object other) => identical(this, other) || other is SystemConfigFFmpegDto &&
other.crf == crf &&
other.threads == threads &&
other.preset == preset &&
other.targetVideoCodec == targetVideoCodec &&
other.targetAudioCodec == targetAudioCodec &&
other.targetResolution == targetResolution &&
other.maxBitrate == maxBitrate &&
other.twoPass == twoPass &&
other.transcode == transcode;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(crf.hashCode) +
(threads.hashCode) +
(preset.hashCode) +
(targetVideoCodec.hashCode) +
(targetAudioCodec.hashCode) +
(targetResolution.hashCode) +
(maxBitrate.hashCode) +
(twoPass.hashCode) +
(transcode.hashCode);
@override
String toString() => 'SystemConfigFFmpegDto[crf=$crf, preset=$preset, targetVideoCodec=$targetVideoCodec, targetAudioCodec=$targetAudioCodec, targetResolution=$targetResolution, transcode=$transcode]';
String toString() => 'SystemConfigFFmpegDto[crf=$crf, threads=$threads, preset=$preset, targetVideoCodec=$targetVideoCodec, targetAudioCodec=$targetAudioCodec, targetResolution=$targetResolution, maxBitrate=$maxBitrate, twoPass=$twoPass, transcode=$transcode]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'crf'] = this.crf;
json[r'threads'] = this.threads;
json[r'preset'] = this.preset;
json[r'targetVideoCodec'] = this.targetVideoCodec;
json[r'targetAudioCodec'] = this.targetAudioCodec;
json[r'targetResolution'] = this.targetResolution;
json[r'maxBitrate'] = this.maxBitrate;
json[r'twoPass'] = this.twoPass;
json[r'transcode'] = this.transcode;
return json;
}
@@ -85,11 +103,14 @@ class SystemConfigFFmpegDto {
}());
return SystemConfigFFmpegDto(
crf: mapValueOfType<String>(json, r'crf')!,
crf: mapValueOfType<int>(json, r'crf')!,
threads: mapValueOfType<int>(json, r'threads')!,
preset: mapValueOfType<String>(json, r'preset')!,
targetVideoCodec: mapValueOfType<String>(json, r'targetVideoCodec')!,
targetAudioCodec: mapValueOfType<String>(json, r'targetAudioCodec')!,
targetResolution: mapValueOfType<String>(json, r'targetResolution')!,
maxBitrate: mapValueOfType<String>(json, r'maxBitrate')!,
twoPass: mapValueOfType<bool>(json, r'twoPass')!,
transcode: SystemConfigFFmpegDtoTranscodeEnum.fromJson(json[r'transcode'])!,
);
}
@@ -139,10 +160,13 @@ class SystemConfigFFmpegDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'crf',
'threads',
'preset',
'targetVideoCodec',
'targetAudioCodec',
'targetResolution',
'maxBitrate',
'twoPass',
'transcode',
};
}

View File

@@ -16,11 +16,16 @@ void main() {
// final instance = SystemConfigFFmpegDto();
group('test SystemConfigFFmpegDto', () {
// String crf
// int crf
test('to test the property `crf`', () async {
// TODO
});
// int threads
test('to test the property `threads`', () async {
// TODO
});
// String preset
test('to test the property `preset`', () async {
// TODO
@@ -41,6 +46,16 @@ void main() {
// TODO
});
// String maxBitrate
test('to test the property `maxBitrate`', () async {
// TODO
});
// bool twoPass
test('to test the property `twoPass`', () async {
// TODO
});
// String transcode
test('to test the property `transcode`', () async {
// TODO