mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-22 02:12:30 +01:00
Make ffmpeg map metadata
This commit is contained in:
parent
60060d4b73
commit
61a13ceabe
@ -56,30 +56,31 @@ function handleProgress(process, cutDuration, onProgress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function cut(customOutDir, filePath, format, cutFrom, cutTo, onProgress) {
|
async function cut(customOutDir, filePath, format, cutFrom, cutTo, onProgress) {
|
||||||
const extWithoutDot = path.extname(filePath) || `.${format}`;
|
const extWithoutDot = path.extname(filePath) || `.${format}`;
|
||||||
const ext = `.${extWithoutDot}`;
|
const ext = `.${extWithoutDot}`;
|
||||||
const duration = `${util.formatDuration(cutFrom)}-${util.formatDuration(cutTo)}`;
|
const duration = `${util.formatDuration(cutFrom)}-${util.formatDuration(cutTo)}`;
|
||||||
|
|
||||||
const outPath = util.getOutPath(customOutDir, filePath, `${duration}${ext}`);
|
const outPath = util.getOutPath(customOutDir, filePath, `${duration}${ext}`);
|
||||||
|
|
||||||
console.log('Cutting from', cutFrom, 'to', cutTo);
|
console.log('Cutting from', cutFrom, 'to', cutTo);
|
||||||
|
|
||||||
const ffmpegArgs = [
|
const ffmpegArgs = [
|
||||||
'-i', filePath, '-y', '-vcodec', 'copy', '-acodec', 'copy',
|
'-i', filePath, '-y', '-vcodec', 'copy', '-acodec', 'copy',
|
||||||
'-ss', cutFrom, '-t', cutTo - cutFrom,
|
'-ss', cutFrom, '-t', cutTo - cutFrom,
|
||||||
'-f', format,
|
'-map_metadata', '0',
|
||||||
outPath,
|
'-f', format,
|
||||||
];
|
outPath,
|
||||||
|
];
|
||||||
|
|
||||||
console.log('ffmpeg', ffmpegArgs.join(' '));
|
console.log('ffmpeg', ffmpegArgs.join(' '));
|
||||||
|
|
||||||
onProgress(0);
|
onProgress(0);
|
||||||
|
|
||||||
const ffmpegPath = await getFfmpegPath();
|
const ffmpegPath = await getFfmpegPath();
|
||||||
const process = execa(ffmpegPath, ffmpegArgs);
|
const process = execa(ffmpegPath, ffmpegArgs);
|
||||||
handleProgress(process, cutTo - cutFrom, onProgress);
|
handleProgress(process, cutTo - cutFrom, onProgress);
|
||||||
const result = await process;
|
const result = await process;
|
||||||
console.log(result.stdout);
|
console.log(result.stdout);
|
||||||
|
|
||||||
return util.transferTimestamps(filePath, outPath);
|
return util.transferTimestamps(filePath, outPath);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user