mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 11:43:17 +01:00
parent
1a674fa735
commit
e7d2caf893
@ -103,6 +103,14 @@ function ExportConfirm({
|
|||||||
// some thumbnail streams (png,jpg etc) cannot always be cut correctly, so we warn if they try to.
|
// some thumbnail streams (png,jpg etc) cannot always be cut correctly, so we warn if they try to.
|
||||||
const areWeCuttingProblematicStreams = areWeCutting && mainCopiedThumbnailStreams.length > 0;
|
const areWeCuttingProblematicStreams = areWeCutting && mainCopiedThumbnailStreams.length > 0;
|
||||||
|
|
||||||
|
const warnings = useMemo(() => {
|
||||||
|
const ret: string[] = [];
|
||||||
|
// https://github.com/mifi/lossless-cut/issues/1809
|
||||||
|
if (areWeCutting && outFormat === 'flac') {
|
||||||
|
ret.push(t('There is a known issue in FFmpeg with cutting FLAC files. The file will be re-encoded, which is still lossless, but the export may be slower.'));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}, [areWeCutting, outFormat, t]);
|
||||||
const exportModeDescription = useMemo(() => ({
|
const exportModeDescription = useMemo(() => ({
|
||||||
segments_to_chapters: t('Don\'t cut the file, but instead export an unmodified original which has chapters generated from segments'),
|
segments_to_chapters: t('Don\'t cut the file, but instead export an unmodified original which has chapters generated from segments'),
|
||||||
merge: t('Auto merge segments to one file after export'),
|
merge: t('Auto merge segments to one file after export'),
|
||||||
@ -208,6 +216,14 @@ function ExportConfirm({
|
|||||||
|
|
||||||
<table className={styles['options']}>
|
<table className={styles['options']}>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{warnings.map((warning) => (
|
||||||
|
<tr key={warning}>
|
||||||
|
<td colSpan={2}>
|
||||||
|
<div style={warningStyle}><WarningSignIcon verticalAlign="middle" color="warning" /> {warnings.join('\n')}</div>
|
||||||
|
</td>
|
||||||
|
<td />
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
{selectedSegments.length !== nonFilteredSegmentsOrInverse.length && (
|
{selectedSegments.length !== nonFilteredSegmentsOrInverse.length && (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={2}>
|
<td colSpan={2}>
|
||||||
|
@ -218,7 +218,8 @@ function useFfmpegOperations({ filePath, treatInputFileModifiedTimeAsStart, trea
|
|||||||
const cuttingStart = isCuttingStart(cutFrom);
|
const cuttingStart = isCuttingStart(cutFrom);
|
||||||
const cutFromWithAdjustment = cutFrom + cutFromAdjustmentFrames * frameDuration;
|
const cutFromWithAdjustment = cutFrom + cutFromAdjustmentFrames * frameDuration;
|
||||||
const cuttingEnd = isCuttingEnd(cutTo, videoDuration);
|
const cuttingEnd = isCuttingEnd(cutTo, videoDuration);
|
||||||
console.log('Cutting from', cuttingStart ? `${cutFrom} (${cutFromWithAdjustment} adjusted ${cutFromAdjustmentFrames} frames)` : 'start', 'to', cuttingEnd ? cutTo : 'end');
|
const areWeCutting = cuttingStart || cuttingEnd;
|
||||||
|
if (areWeCutting) console.log('Cutting from', cuttingStart ? `${cutFrom} (${cutFromWithAdjustment} adjusted ${cutFromAdjustmentFrames} frames)` : 'start', 'to', cuttingEnd ? cutTo : 'end');
|
||||||
|
|
||||||
let cutDuration = cutTo - cutFromWithAdjustment;
|
let cutDuration = cutTo - cutFromWithAdjustment;
|
||||||
if (detectedFps != null) cutDuration = Math.max(cutDuration, frameDuration); // ensure at least one frame duration
|
if (detectedFps != null) cutDuration = Math.max(cutDuration, frameDuration); // ensure at least one frame duration
|
||||||
@ -279,7 +280,7 @@ function useFfmpegOperations({ filePath, treatInputFileModifiedTimeAsStart, trea
|
|||||||
...flatMap(Object.entries(customTagsByFile[filePath] || []), ([key, value]) => ['-metadata', `${key}=${value}`]),
|
...flatMap(Object.entries(customTagsByFile[filePath] || []), ([key, value]) => ['-metadata', `${key}=${value}`]),
|
||||||
];
|
];
|
||||||
|
|
||||||
const mapStreamsArgs = getMapStreamsArgs({ copyFileStreams: copyFileStreamsFiltered, allFilesMeta, outFormat });
|
const mapStreamsArgs = getMapStreamsArgs({ copyFileStreams: copyFileStreamsFiltered, allFilesMeta, outFormat, areWeCutting });
|
||||||
|
|
||||||
const customParamsArgs = (() => {
|
const customParamsArgs = (() => {
|
||||||
const ret: string[] = [];
|
const ret: string[] = [];
|
||||||
|
@ -169,6 +169,8 @@ function getPerStreamFlags({ stream, outputIndex, outFormat, manuallyCopyDisposi
|
|||||||
// I think DV format only supports PCM_S16LE https://github.com/FFmpeg/FFmpeg/blob/b92028346c35dad837dd1160930435d88bd838b5/libavformat/dvenc.c#L450
|
// I think DV format only supports PCM_S16LE https://github.com/FFmpeg/FFmpeg/blob/b92028346c35dad837dd1160930435d88bd838b5/libavformat/dvenc.c#L450
|
||||||
addCodecArgs('pcm_s16le');
|
addCodecArgs('pcm_s16le');
|
||||||
addArgs(`-ar:${outputIndex}`, '48000'); // maybe technically not lossless?
|
addArgs(`-ar:${outputIndex}`, '48000'); // maybe technically not lossless?
|
||||||
|
} else if (outFormat === 'flac' && areWeCutting && stream.codec_name === 'flac') { // https://github.com/mifi/lossless-cut/issues/1809
|
||||||
|
addCodecArgs('flac'); // lossless because flac is a lossless codec
|
||||||
} else {
|
} else {
|
||||||
addCodecArgs('copy');
|
addCodecArgs('copy');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user