Skip to content

The swiss army knife of lossless video/audio editing

add supported conversion: "Fastest: Low playback speed (audio remux), likely to fail" #424

Mikael Finstaddffd1e448eb2
diff --git a/src/App.jsx b/src/App.jsx
index 068edece..9f56cc4c 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -47,7 +47,7 @@ import {
defaultProcessedCodecTypes, getStreamFps, isCuttingStart, isCuttingEnd,
getDefaultOutFormat, getFormatData, renderThumbnails as ffmpegRenderThumbnails,
extractStreams, getAllStreams,
- isStreamThumbnail, isAudioSupported, isIphoneHevc, tryReadChaptersToEdl,
+ isStreamThumbnail, isAudioDefinitelyNotSupported, isIphoneHevc, tryReadChaptersToEdl,
getDuration, getTimecodeFromStreams, createChaptersFromSegments,
} from './ffmpeg';
import { saveCsv, saveTsv, loadCsv, loadXmeml, loadCue, loadPbf, loadMplayerEdl, saveCsvHuman, saveLlcProject, loadLlcProject } from './edlStore';
@@ -1210,7 +1210,7 @@ const App = memo(() => {
setWorking(i18n.t('Loading file'));
async function checkAndSetExistingHtml5FriendlyFile() {
- const speeds = ['slowest', 'slow-audio', 'slow', 'fast-audio', 'fast', 'fastest-audio', html5dummySuffix];
+ const speeds = ['slowest', 'slow-audio', 'slow', 'fast-audio', 'fast', 'fastest-audio', 'fastest-audio-remux', html5dummySuffix];
const prefix = `${getFileBaseName(fp)}-${html5ifiedPrefix}`;
const outDir = getOutDir(cod, fp);
@@ -1233,7 +1233,7 @@ const App = memo(() => {
if (!path) return false;
console.log('Found existing supported file', path, speed);
- setUsingDummyVideo(speed === 'fastest-audio');
+ setUsingDummyVideo(['fastest-audio', 'fastest-audio-remux'].includes(speed));
setPreviewFilePath(path);
showPreviewFileLoadedMessage(basename(path));
@@ -1284,7 +1284,7 @@ const App = memo(() => {
setDetectedFileFormat(ff);
setFileFormatData(fd);
- if (!isAudioSupported(streams)) {
+ if (isAudioDefinitelyNotSupported(streams)) {
toast.fire({ icon: 'info', text: i18n.t('The audio track is not supported. You can convert to a supported format from the menu') });
}
@@ -1633,8 +1633,8 @@ const App = memo(() => {
let audio;
if (ha) {
if (speed === 'slowest') audio = 'hq';
- else if (speed === 'slow-audio' || speed === 'fastest-audio') audio = 'lq';
- else if (speed === 'fast-audio') audio = 'copy';
+ else if (['slow-audio', 'fastest-audio'].includes(speed)) audio = 'lq';
+ else if (['fast-audio', 'fastest-audio-remux'].includes(speed)) audio = 'copy';
}
let video;
@@ -1653,7 +1653,7 @@ const App = memo(() => {
}, [ffmpegHtml5ify, getHtml5ifiedPath]);
const html5ifyAndLoad = useCallback(async (speed) => {
- if (speed === 'fastest-audio') {
+ if (['fastest-audio', 'fastest-audio-remux'].includes(speed)) {
const path = await html5ify({ customOutDir, filePath, speed, hasAudio, hasVideo: false });
load({ filePath, dummyVideoPathRequested: path, customOutDir });
} else {
@@ -1662,18 +1662,18 @@ const App = memo(() => {
}
}, [hasAudio, hasVideo, customOutDir, filePath, html5ify, load]);
- const html5ifyCurrentFile = useCallback(async () => {
+ const userHtml5ifyCurrentFile = useCallback(async () => {
if (!filePath) return;
try {
setWorking(i18n.t('Converting to supported format'));
- const speed = await askForHtml5ifySpeed(['fastest', 'fastest-audio', 'fast-audio', 'fast', 'slow', 'slow-audio', 'slowest']);
+ const speed = await askForHtml5ifySpeed(['fastest', 'fastest-audio', 'fastest-audio-remux', 'fast-audio', 'fast', 'slow', 'slow-audio', 'slowest']);
if (!speed) return;
if (speed === 'fastest') {
await createDummyVideo(customOutDir, filePath);
- } else if (['fastest-audio', 'fast-audio', 'fast', 'slow', 'slow-audio', 'slowest'].includes(speed)) {
+ } else if (['fastest-audio', 'fastest-audio-remux', 'fast-audio', 'fast', 'slow', 'slow-audio', 'slowest'].includes(speed)) {
await html5ifyAndLoad(speed);
}
} catch (err) {
@@ -1798,7 +1798,7 @@ const App = memo(() => {
const failedFiles = [];
let i = 0;
- const speed = await askForHtml5ifySpeed(['fastest-audio', 'fast-audio', 'fast', 'slow', 'slow-audio', 'slowest']);
+ const speed = await askForHtml5ifySpeed(['fastest-audio', 'fastest-audio-remux', 'fast-audio', 'fast', 'slow', 'slow-audio', 'slowest']);
if (!speed) return;
try {
@@ -1870,7 +1870,7 @@ const App = memo(() => {
electron.ipcRenderer.on('file-opened', fileOpened);
electron.ipcRenderer.on('close-file', closeFile2);
- electron.ipcRenderer.on('html5ify', html5ifyCurrentFile);
+ electron.ipcRenderer.on('html5ify', userHtml5ifyCurrentFile);
electron.ipcRenderer.on('show-merge-dialog', showOpenAndMergeDialog2);
electron.ipcRenderer.on('set-start-offset', setStartOffset);
electron.ipcRenderer.on('extract-all-streams', extractAllStreams);
@@ -1893,7 +1893,7 @@ const App = memo(() => {
return () => {
electron.ipcRenderer.removeListener('file-opened', fileOpened);
electron.ipcRenderer.removeListener('close-file', closeFile2);
- electron.ipcRenderer.removeListener('html5ify', html5ifyCurrentFile);
+ electron.ipcRenderer.removeListener('html5ify', userHtml5ifyCurrentFile);
electron.ipcRenderer.removeListener('show-merge-dialog', showOpenAndMergeDialog2);
electron.ipcRenderer.removeListener('set-start-offset', setStartOffset);
electron.ipcRenderer.removeListener('extract-all-streams', extractAllStreams);
@@ -1914,7 +1914,7 @@ const App = memo(() => {
electron.ipcRenderer.removeListener('reorderSegsByStartTime', reorderSegsByStartTime);
};
}, [
- mergeFiles, outputDir, filePath, customOutDir, startTimeOffset, html5ifyCurrentFile,
+ mergeFiles, outputDir, filePath, customOutDir, startTimeOffset, userHtml5ifyCurrentFile,
createDummyVideo, extractAllStreams, userOpenFiles, openSendReportDialogWithState,
loadEdlFile, cutSegments, apparentCutSegments, edlFilePath, toggleHelp, toggleSettings, assureOutDirAccess, html5ifyAndLoad, html5ify,
loadCutSegments, duration, checkFileOpened, load, fileFormat, reorderSegsByStartTime, closeFile, clearSegments, fixInvalidDuration, invertAllCutSegments,
diff --git a/src/components/VolumeControl.jsx b/src/components/VolumeControl.jsx
index 3fca9944..d2b6a6ac 100644
--- a/src/components/VolumeControl.jsx
+++ b/src/components/VolumeControl.jsx
@@ -28,7 +28,7 @@ const VolumeControl = memo(({ playbackVolume, setPlaybackVolume, usingDummyVideo
}
}, [volumeControlVisible, setPlaybackVolume, playbackVolume]);
- // TODO fastest-audio currently shows as muted
+ // TODO fastest-audio/fastest-audio-remux currently shows as muted
const VolumeIcon = playbackVolume === 0 || usingDummyVideo ? FaVolumeMute : FaVolumeUp;
return (
diff --git a/src/dialogs.jsx b/src/dialogs.jsx
index d4ccb558..e03727ac 100644
--- a/src/dialogs.jsx
+++ b/src/dialogs.jsx
@@ -47,6 +47,7 @@ export async function askForHtml5ifySpeed(allowedOptions) {
const availOptions = {
fastest: i18n.t('Fastest: Low playback speed (no audio)'),
'fastest-audio': i18n.t('Fastest: Low playback speed'),
+ 'fastest-audio-remux': i18n.t('Fastest: Low playback speed (audio remux), likely to fail'),
fast: i18n.t('Fast: Full quality remux (no audio), likely to fail'),
'fast-audio': i18n.t('Fast: Full quality remux, likely to fail'),
slow: i18n.t('Slow: Low quality encode (no audio)'),
diff --git a/src/ffmpeg.js b/src/ffmpeg.js
index a21f966b..3ba2fc9d 100644
--- a/src/ffmpeg.js
+++ b/src/ffmpeg.js
@@ -464,11 +464,13 @@ export function isStreamThumbnail(stream) {
return stream && stream.disposition && stream.disposition.attached_pic === 1;
}
-export function isAudioSupported(streams) {
- const audioStreams = streams.filter(stream => stream.codec_type === 'audio');
- if (audioStreams.length === 0) return true;
+const getAudioStreams = (streams) => streams.filter(stream => stream.codec_type === 'audio');
+
+export function isAudioDefinitelyNotSupported(streams) {
+ const audioStreams = getAudioStreams(streams);
+ if (audioStreams.length === 0) return false;
// TODO this could be improved
- return audioStreams.some(stream => !['ac3'].includes(stream.codec_name));
+ return audioStreams.every(stream => ['ac3'].includes(stream.codec_name));
}
export function isIphoneHevc(format, streams) {