mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 15:36:18 -05:00
Transcode modal: allow a container-only remux
Keeping both streams is no longer refused: ffmpeg copies them into the chosen container with fast start. The container select starts at the file's own container, the hint explains what a remux does, and the button reads Remux when nothing is re-encoded. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
ca1dc82aa9
commit
749d5ac32b
5 changed files with 100 additions and 22 deletions
|
|
@ -1,7 +1,9 @@
|
|||
import React from 'react';
|
||||
import {act, fireEvent, screen, waitFor} from '@testing-library/react';
|
||||
import {renderWithProviders} from '../test-utils';
|
||||
import {currentCodecs, EditVideoModal, JobProgress, preferredTarget, TranscodeModal, VideoEditMenu} from './VideoEditMenu';
|
||||
import {
|
||||
currentCodecs, currentContainer, EditVideoModal, JobProgress, preferredTarget, TranscodeModal, VideoEditMenu,
|
||||
} from './VideoEditMenu';
|
||||
import {TRANSCODE_COPY, transcodeAudioCodecOptions, transcodeVideoCodecOptions} from './Vars';
|
||||
|
||||
jest.mock('../api', () => ({
|
||||
|
|
@ -39,6 +41,13 @@ describe('helpers', () => {
|
|||
expect(currentCodecs(null)).toEqual({video: [], audio: []});
|
||||
});
|
||||
|
||||
test('currentContainer reads the file suffix, only for containers we can write', () => {
|
||||
expect(currentContainer({video_path: 'videos/a/movie.MP4'})).toBe('mp4');
|
||||
expect(currentContainer({video_path: 'videos/a/movie.mkv'})).toBe('mkv');
|
||||
expect(currentContainer({video_path: 'videos/a/movie.webm'})).toBeNull();
|
||||
expect(currentContainer(null)).toBeNull();
|
||||
});
|
||||
|
||||
test('preferredTarget picks the first preference ffmpeg can produce', () => {
|
||||
expect(preferredTarget(['vp9', 'h264'], transcodeVideoCodecOptions)).toBe('h264');
|
||||
expect(preferredTarget(['vp9', 'av1'], transcodeVideoCodecOptions)).toBe(TRANSCODE_COPY);
|
||||
|
|
@ -77,13 +86,30 @@ describe('TranscodeModal', () => {
|
|||
expect(await screen.findByText('pending')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('refuses to start when every stream is kept', async () => {
|
||||
test('keeping every stream is a remux into the chosen container', async () => {
|
||||
fetchVideoDownloadDefaults.mockResolvedValue({video_codecs: [], audio_codecs: []});
|
||||
// A webm cannot be kept (not a container we write), so the select starts at mp4: a change.
|
||||
renderWithProviders(<TranscodeModal open={true} onClose={jest.fn()} fileGroupId={7} video={video}/>);
|
||||
|
||||
await waitFor(() => expect(screen.getByText('Choose at least one codec to convert.')).toBeInTheDocument());
|
||||
expect(screen.getByRole('button', {name: /Transcode/})).toBeDisabled();
|
||||
expect(transcodeVideo).not.toHaveBeenCalled();
|
||||
await waitFor(() => expect(selectInput('Container')).toHaveValue('mp4'));
|
||||
expect(await screen.findByText(/only the container changes to mp4/)).toBeInTheDocument();
|
||||
|
||||
const button = screen.getByRole('button', {name: 'Remux'});
|
||||
expect(button).toBeEnabled();
|
||||
fireEvent.click(button);
|
||||
await waitFor(() => expect(transcodeVideo).toHaveBeenCalledWith(7, {
|
||||
video_codec: null, audio_codec: null, container: 'mp4',
|
||||
}));
|
||||
});
|
||||
|
||||
test('a remux into the same container is described as a fast-start rewrite', async () => {
|
||||
fetchVideoDownloadDefaults.mockResolvedValue({video_codecs: [], audio_codecs: []});
|
||||
const mkv = {...video, video_path: 'videos/movie.mkv'};
|
||||
renderWithProviders(<TranscodeModal open={true} onClose={jest.fn()} fileGroupId={7} video={mkv}/>);
|
||||
|
||||
await waitFor(() => expect(selectInput('Container')).toHaveValue('mkv'));
|
||||
expect(await screen.findByText(/rewritten as-is with fast start/)).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', {name: 'Remux'})).toBeEnabled();
|
||||
});
|
||||
|
||||
test('WROL Mode disables starting a transcode', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue