Skip to content

Commit

Permalink
chore(server): change transcode default to accept all supported audio…
Browse files Browse the repository at this point in the history
… codecs (#7283)

* change transcode defaults

* don't untick accepted audio codecs

* no need to change the transcode policy

* fix tests

* remove log
  • Loading branch information
mertalev committed Feb 21, 2024
1 parent 7c34d05 commit 397570a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 43 deletions.
82 changes: 43 additions & 39 deletions server/src/domain/media/media.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AssetType,
AudioCodec,
Colorspace,
ExifEntity,
SystemConfigKey,
Expand Down Expand Up @@ -475,7 +476,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -542,7 +543,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -571,7 +572,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -629,7 +630,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -706,7 +707,10 @@ describe(MediaService.name, () => {

it('should copy video stream when video matches target', async () => {
mediaMock.probe.mockResolvedValue(probeStub.matroskaContainer);
configMock.load.mockResolvedValue([{ key: SystemConfigKey.FFMPEG_TARGET_VIDEO_CODEC, value: VideoCodec.HEVC }]);
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.FFMPEG_TARGET_VIDEO_CODEC, value: VideoCodec.HEVC },
{ key: SystemConfigKey.FFMPEG_ACCEPTED_AUDIO_CODECS, value: [AudioCodec.AAC] },
]);
assetMock.getByIds.mockResolvedValue([assetStub.video]);
await sut.handleVideoConversion({ id: assetStub.video.id });
expect(mediaMock.transcode).toHaveBeenCalledWith(
Expand Down Expand Up @@ -770,7 +774,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -836,7 +840,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -868,7 +872,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -897,7 +901,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -928,7 +932,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v vp9',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -962,7 +966,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v vp9',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -994,7 +998,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v vp9',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1026,7 +1030,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v vp9',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1057,7 +1061,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v vp9',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1087,7 +1091,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1117,7 +1121,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1147,7 +1151,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v hevc',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1181,7 +1185,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v hevc',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1248,7 +1252,7 @@ describe(MediaService.name, () => {
'-rc-lookahead 20',
'-i_qfactor 0.75',
`-c:v h264_nvenc`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1286,7 +1290,7 @@ describe(MediaService.name, () => {
'-rc-lookahead 20',
'-i_qfactor 0.75',
`-c:v h264_nvenc`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1320,7 +1324,7 @@ describe(MediaService.name, () => {
'-rc-lookahead 20',
'-i_qfactor 0.75',
`-c:v h264_nvenc`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1355,7 +1359,7 @@ describe(MediaService.name, () => {
'-rc-lookahead 20',
'-i_qfactor 0.75',
`-c:v h264_nvenc`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1386,7 +1390,7 @@ describe(MediaService.name, () => {
'-rc-lookahead 20',
'-i_qfactor 0.75',
`-c:v h264_nvenc`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1418,7 +1422,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device qsv=hw', '-filter_hw_device hw'],
outputOptions: [
`-c:v h264_qsv`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1455,7 +1459,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device qsv=hw,child_device=/dev/dri/renderD128', '-filter_hw_device hw'],
outputOptions: [
`-c:v h264_qsv`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1491,7 +1495,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device qsv=hw', '-filter_hw_device hw'],
outputOptions: [
`-c:v h264_qsv`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1524,7 +1528,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device qsv=hw', '-filter_hw_device hw'],
outputOptions: [
`-c:v vp9_qsv`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1568,7 +1572,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'],
outputOptions: [
`-c:v h264_vaapi`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1600,7 +1604,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'],
outputOptions: [
`-c:v h264_vaapi`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1634,7 +1638,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'],
outputOptions: [
`-c:v h264_vaapi`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1664,7 +1668,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/card1', '-filter_hw_device accel'],
outputOptions: [
`-c:v h264_vaapi`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand All @@ -1690,7 +1694,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD129', '-filter_hw_device accel'],
outputOptions: [
`-c:v h264_vaapi`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1724,7 +1728,7 @@ describe(MediaService.name, () => {
inputOptions: ['-init_hw_device vaapi=accel:/dev/dri/renderD128', '-filter_hw_device accel'],
outputOptions: [
`-c:v h264_vaapi`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1757,7 +1761,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1798,7 +1802,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
`-c:v hevc_rkmpp_encoder`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1838,7 +1842,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
`-c:v h264_rkmpp_encoder`,
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down Expand Up @@ -1872,7 +1876,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand All @@ -1899,7 +1903,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand All @@ -1926,7 +1930,7 @@ describe(MediaService.name, () => {
inputOptions: [],
outputOptions: [
'-c:v h264',
'-c:a aac',
'-c:a copy',
'-movflags faststart',
'-fps_mode passthrough',
'-map 0:0',
Expand Down
2 changes: 1 addition & 1 deletion server/src/domain/system-config/system-config.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const defaults = Object.freeze<SystemConfig>({
targetVideoCodec: VideoCodec.H264,
acceptedVideoCodecs: [VideoCodec.H264],
targetAudioCodec: AudioCodec.AAC,
acceptedAudioCodecs: [AudioCodec.AAC],
acceptedAudioCodecs: [AudioCodec.AAC, AudioCodec.MP3, AudioCodec.LIBOPUS],
targetResolution: '720',
maxBitrate: '0',
bframes: -1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const updatedConfig = Object.freeze<SystemConfig>({
threads: 0,
preset: 'ultrafast',
targetAudioCodec: AudioCodec.AAC,
acceptedAudioCodecs: [AudioCodec.AAC],
acceptedAudioCodecs: [AudioCodec.AAC, AudioCodec.MP3, AudioCodec.LIBOPUS],
targetResolution: '720',
targetVideoCodec: VideoCodec.H264,
acceptedVideoCodecs: [VideoCodec.H264],
Expand Down
2 changes: 1 addition & 1 deletion server/src/infra/entities/system-config.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class SystemConfigEntity<T = SystemConfigValue> {
key!: SystemConfigKey;

@Column({ type: 'varchar', nullable: true, transformer: { to: JSON.stringify, from: JSON.parse } })
value!: T;
value!: T | T[];
}

export type SystemConfigValue = string | number | boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@
]}
name="acodec"
isEdited={config.ffmpeg.targetAudioCodec !== savedConfig.ffmpeg.targetAudioCodec}
on:select={() => (config.ffmpeg.acceptedAudioCodecs = [config.ffmpeg.targetAudioCodec])}
on:select={() =>
config.ffmpeg.acceptedAudioCodecs.includes(config.ffmpeg.targetAudioCodec)
? null
: config.ffmpeg.acceptedAudioCodecs.push(config.ffmpeg.targetAudioCodec)}
/>

<SettingCheckboxes
Expand Down

0 comments on commit 397570a

Please sign in to comment.