From 826cb5743c8238b7402271b66a5ec176f7876ae8 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Mon, 27 Apr 2020 13:17:08 +0800 Subject: [PATCH] use correct stream index if more than one --- src/App.jsx | 4 ++-- src/CanvasPlayer.js | 6 +++--- src/ffmpeg.js | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 862dd13f..c27d0e38 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -820,7 +820,7 @@ const App = memo(() => { useEffect(() => () => waveform && URL.revokeObjectURL(waveform.url), [waveform]); function showUnsupportedFileMessage() { - toast.fire({ timer: 10000, icon: 'info', title: i18n.t('File not natively supported'), text: i18n.t('There will be no audio and a low quality preview. The final export will however be lossless and contains audio. You may convert it from the menu for a better preview') }); + toast.fire({ timer: 10000, icon: 'info', title: i18n.t('File not natively supported'), text: i18n.t('Preview will have no audio and low quality. The final export will however be lossless with audio. You may convert it from the menu for a better preview.') }); } const createDummyVideo = useCallback(async (cod, fp) => { @@ -1797,7 +1797,7 @@ const App = memo(() => { onError={onVideoError} /> - {canvasPlayerEnabled && } + {canvasPlayerEnabled && } {isRotationSet && ( diff --git a/src/CanvasPlayer.js b/src/CanvasPlayer.js index 96f5b3d7..470ba574 100644 --- a/src/CanvasPlayer.js +++ b/src/CanvasPlayer.js @@ -3,7 +3,7 @@ import { encodeLiveRawStream, getOneRawFrame } from './ffmpeg'; // TODO keep everything in electron land? const strtok3 = window.require('strtok3'); -export default ({ path, width: inWidth, height: inHeight }) => { +export default ({ path, width: inWidth, height: inHeight, streamIndex }) => { let canvas; let terminated; @@ -35,7 +35,7 @@ export default ({ path, width: inWidth, height: inHeight }) => { if (playing) { try { - const { process: processIn, channels, width, height } = encodeLiveRawStream({ path, inWidth, inHeight, seekTo: commandedTime }); + const { process: processIn, channels, width, height } = encodeLiveRawStream({ path, inWidth, inHeight, streamIndex, seekTo: commandedTime }); process = processIn; // process.stderr.on('data', data => console.log(data.toString('utf-8'))); @@ -55,7 +55,7 @@ export default ({ path, width: inWidth, height: inHeight }) => { } } else { try { - const { process: processIn, width, height } = getOneRawFrame({ path, inWidth, inHeight, seekTo: commandedTime }); + const { process: processIn, width, height } = getOneRawFrame({ path, inWidth, inHeight, streamIndex, seekTo: commandedTime }); process = processIn; const { stdout: rgbaImage } = await process; diff --git a/src/ffmpeg.js b/src/ffmpeg.js index 937819c2..4b182bec 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -712,7 +712,7 @@ export function getStreamFps(stream) { return undefined; } -function createRawFfmpeg({ fps = 25, path, inWidth, inHeight, seekTo, oneFrameOnly, execaOpts }) { +function createRawFfmpeg({ fps = 25, path, inWidth, inHeight, seekTo, oneFrameOnly, execaOpts, streamIndex }) { // const fps = 25; // TODO const aspectRatio = inWidth / inHeight; @@ -739,7 +739,7 @@ function createRawFfmpeg({ fps = 25, path, inWidth, inHeight, seekTo, oneFrameOn '-i', path, '-vf', `fps=${fps},scale=${newWidth}:${newHeight}:flags=lanczos`, - '-map', 'v:0', + '-map', `0:${streamIndex}`, '-vcodec', 'rawvideo', '-pix_fmt', 'rgba', @@ -759,13 +759,13 @@ function createRawFfmpeg({ fps = 25, path, inWidth, inHeight, seekTo, oneFrameOn }; } -export function getOneRawFrame({ path, inWidth, inHeight, seekTo }) { - const { process, width, height, channels } = createRawFfmpeg({ path, inWidth, inHeight, seekTo, oneFrameOnly: true, execaOpts: { encoding: null } }); +export function getOneRawFrame({ path, inWidth, inHeight, seekTo, streamIndex }) { + const { process, width, height, channels } = createRawFfmpeg({ path, inWidth, inHeight, seekTo, streamIndex, oneFrameOnly: true, execaOpts: { encoding: null } }); return { process, width, height, channels }; } -export function encodeLiveRawStream({ path, inWidth, inHeight, seekTo }) { - const { process, width, height, channels } = createRawFfmpeg({ path, inWidth, inHeight, seekTo, execaOpts: { encoding: null, buffer: false } }); +export function encodeLiveRawStream({ path, inWidth, inHeight, seekTo, streamIndex }) { + const { process, width, height, channels } = createRawFfmpeg({ path, inWidth, inHeight, seekTo, streamIndex, execaOpts: { encoding: null, buffer: false } }); return { process,