mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 09:26:17 -05:00
videos: transcode can remove the audio stream (silent video) (#737)
A video's audio stream can be dropped the same way its video stream could already be: a new REMOVE_AUDIO audio target maps only the video stream with -an, needs a video container, and is refused for audio files. Output verification insists the result has no audio stream. Removing both streams is refused by the validator, the API, resolve_output, and the modal: choosing Remove for one stream resets the other to Keep and withdraws the other's Remove option. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
63ddad69e8
commit
15d3792b0e
7 changed files with 291 additions and 30 deletions
|
|
@ -2,11 +2,11 @@ import React from 'react';
|
|||
import {act, fireEvent, screen, waitFor} from '@testing-library/react';
|
||||
import {renderWithProviders} from '../test-utils';
|
||||
import {
|
||||
containerFor, currentCodecs, currentContainer, EditVideoModal, JobProgress, preferredTarget, TranscodeModal,
|
||||
useJob, VideoEditMenu,
|
||||
audioCodecOptionsFor, chooseCodecs, containerFor, currentCodecs, currentContainer, EditVideoModal, JobProgress, preferredTarget,
|
||||
TranscodeModal, useJob, VideoEditMenu, videoCodecOptionsFor,
|
||||
} from './VideoEditMenu';
|
||||
import {
|
||||
audioContainerForCodec, TRANSCODE_COPY, TRANSCODE_REMOVE_VIDEO, transcodeAudioCodecOptions,
|
||||
audioContainerForCodec, TRANSCODE_COPY, TRANSCODE_REMOVE_AUDIO, TRANSCODE_REMOVE_VIDEO, transcodeAudioCodecOptions,
|
||||
transcodeVideoCodecOptions,
|
||||
} from './Vars';
|
||||
|
||||
|
|
@ -221,6 +221,35 @@ describe('TranscodeModal', () => {
|
|||
// Selecting it is exercised through containerFor (Mantine's dropdown is not driveable in jsdom).
|
||||
});
|
||||
|
||||
test('the Remove audio option is offered for videos, not audio files, and never with Remove video', () => {
|
||||
expect(transcodeAudioCodecOptions.some(i => i.value === TRANSCODE_REMOVE_AUDIO)).toBe(true);
|
||||
const has = (options, value) => options.some(i => i.value === value);
|
||||
expect(has(audioCodecOptionsFor({audioOnly: false, removeVideo: false}), TRANSCODE_REMOVE_AUDIO)).toBe(true);
|
||||
expect(has(audioCodecOptionsFor({audioOnly: true, removeVideo: false}), TRANSCODE_REMOVE_AUDIO)).toBe(false);
|
||||
expect(has(audioCodecOptionsFor({audioOnly: false, removeVideo: true}), TRANSCODE_REMOVE_AUDIO)).toBe(false);
|
||||
// The real codecs and Keep are never withdrawn.
|
||||
expect(audioCodecOptionsFor({audioOnly: true, removeVideo: false}).map(i => i.value))
|
||||
.toEqual([TRANSCODE_COPY, 'aac', 'opus', 'mp3']);
|
||||
expect(has(videoCodecOptionsFor({removeAudio: false}), TRANSCODE_REMOVE_VIDEO)).toBe(true);
|
||||
expect(has(videoCodecOptionsFor({removeAudio: true}), TRANSCODE_REMOVE_VIDEO)).toBe(false);
|
||||
expect(has(videoCodecOptionsFor({removeAudio: true}), 'h264')).toBe(true);
|
||||
});
|
||||
|
||||
test('Remove video and Remove audio can never be chosen together', () => {
|
||||
const keepBoth = {videoCodec: TRANSCODE_COPY, audioCodec: TRANSCODE_COPY};
|
||||
// Removing one stream after the other was chosen puts the other back to Keep.
|
||||
expect(chooseCodecs({videoCodec: TRANSCODE_REMOVE_VIDEO, audioCodec: 'aac'}, {audio: TRANSCODE_REMOVE_AUDIO}))
|
||||
.toEqual({videoCodec: TRANSCODE_COPY, audioCodec: TRANSCODE_REMOVE_AUDIO});
|
||||
expect(chooseCodecs({videoCodec: 'h264', audioCodec: TRANSCODE_REMOVE_AUDIO}, {video: TRANSCODE_REMOVE_VIDEO}))
|
||||
.toEqual({videoCodec: TRANSCODE_REMOVE_VIDEO, audioCodec: TRANSCODE_COPY});
|
||||
// Ordinary choices are untouched; a cleared select means Keep.
|
||||
expect(chooseCodecs(keepBoth, {video: 'h264'})).toEqual({videoCodec: 'h264', audioCodec: TRANSCODE_COPY});
|
||||
expect(chooseCodecs({videoCodec: 'h264', audioCodec: 'aac'}, {audio: null}))
|
||||
.toEqual({videoCodec: 'h264', audioCodec: TRANSCODE_COPY});
|
||||
expect(chooseCodecs(keepBoth, {audio: TRANSCODE_REMOVE_AUDIO}))
|
||||
.toEqual({videoCodec: TRANSCODE_COPY, audioCodec: TRANSCODE_REMOVE_AUDIO});
|
||||
});
|
||||
|
||||
test('WROL Mode disables starting a transcode', async () => {
|
||||
renderWithProviders(
|
||||
<TranscodeModal open={true} onClose={jest.fn()} fileGroupId={7} video={video}/>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue