use correct stream index if more than one

pull/333/head
Mikael Finstad 2020-04-27 13:17:08 +08:00
rodzic 9c0c1292db
commit 826cb5743c
3 zmienionych plików z 11 dodań i 11 usunięć

Wyświetl plik

@ -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 && <Canvas rotate={effectiveRotation} filePath={filePath} width={mainVideoStream.width} height={mainVideoStream.height} playerTime={playerTime} commandedTime={commandedTime} playing={playing} />}
{canvasPlayerEnabled && <Canvas rotate={effectiveRotation} filePath={filePath} width={mainVideoStream.width} height={mainVideoStream.height} streamIndex={mainVideoStream.index} playerTime={playerTime} commandedTime={commandedTime} playing={playing} />}
</div>
{isRotationSet && (

Wyświetl plik

@ -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;

Wyświetl plik

@ -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,