Skip to content

Commit

Permalink
Fix transcoding resolutions when audio is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Oct 29, 2024
1 parent 18d9858 commit 7d5d7f2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions packages/tests/src/api/transcoding/transcoder-limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,23 @@ describe('Test video transcoding limits', function () {
expect(video.files[0].resolution.id).to.equal(720)
expect(hlsFiles[0].resolution.id).to.equal(720)
})

it('Should keep input resolution if only upper resolutions are enabled', async function () {
this.timeout(120_000)

await servers[0].config.enableTranscoding({ resolutions: [ 0, 1080 ], keepOriginal: false })

const { uuid } = await servers[0].videos.quickUpload({ name: 'video', fixture: 'video_short.webm' })
await waitJobs(servers)

const video = await servers[0].videos.get({ id: uuid })
const hlsFiles = video.streamingPlaylists[0].files

expect(video.files).to.have.lengthOf(2)
expect(hlsFiles).to.have.lengthOf(2)

expect(getAllFiles(video).map(f => f.resolution.id)).to.have.members([ 720, 720, 0, 0 ])
})
})

after(async function () {
Expand Down
7 changes: 5 additions & 2 deletions server/core/lib/transcoding/transcoding-resolutions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export function buildOriginalFileResolution (inputResolution: number) {
hasAudio: true
})

if (resolutions.length === 0) {
if (
resolutions.length === 0 ||
(resolutions.length === 1 && resolutions[0] === VideoResolution.H_NOVIDEO)
) {
return toEven(inputResolution)
}

Expand Down Expand Up @@ -58,7 +61,7 @@ export function computeResolutionsToTranscode (options: {
if (input < resolution) continue
// We only want lower resolutions than input file
if (strictLower && input === resolution) continue
// Audio resolutio but no audio in the video
// Audio resolution but no audio in the video
if (resolution === VideoResolution.H_NOVIDEO && !hasAudio) continue

resolutionsEnabled.add(resolution)
Expand Down

0 comments on commit 7d5d7f2

Please sign in to comment.