From 349375999823831fdfcb3b777110ad7ca2547103 Mon Sep 17 00:00:00 2001 From: mmcw-dev Date: Sun, 10 Feb 2019 14:07:07 -0500 Subject: [PATCH] Scale frame export to video's advertized size --- app/lib/ffmpeg/index.js | 20 ++++++++++++-------- app/main.js | 16 ++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/lib/ffmpeg/index.js b/app/lib/ffmpeg/index.js index dfa7d30..d6bdb0e 100644 --- a/app/lib/ffmpeg/index.js +++ b/app/lib/ffmpeg/index.js @@ -20,20 +20,24 @@ function padded_frame (i) { return str; } -async function frame (video, frame, obj) { - let padded = padded_frame(frame); - let ext = 'tif'; - let tmpoutput; - let cmd; - let output; +async function frame (state) { + let frame = state.frame + let video = state.path + let w = state.info.width + let h = state.info.height + let padded = padded_frame(frame) + let ext = 'tif' + let tmpoutput + let cmd + let output if (system.platform !== 'nix') { - ext = 'png'; + ext = 'png' } tmpoutput = path.join(TMPDIR, `export-${padded}.${ext}`) - cmd = `ffmpeg -i "${video}" -vf select='gte(n\\,${frame})' -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"` + cmd = `ffmpeg -i "${video}" -vf "select='gte(n\\,${frame})',scale=${w}:${h}" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"` //ffmpeg -i "${video}" -ss 00:00:07.000 -vframes 1 "export-${time}.jpg" //ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "export-%05d.tiff" diff --git a/app/main.js b/app/main.js index 14bb34f..1a88013 100644 --- a/app/main.js +++ b/app/main.js @@ -554,23 +554,23 @@ dig.move = async function () { if (last > 0) { display.end() - //wipe last frame - try { - await ffmpeg.clear(last) - } catch (err) { - console.error(err) - } } try { - await ffmpeg.frame(dig.state.path, dig.state.frame) + await ffmpeg.clearAll() + } catch (err) { + console.error(err) + } + + try { + await ffmpeg.frame(dig.state) } catch (err) { console.error(err) } display.start(dig.state.frame) - await delay(100) + await delay(600) return (+new Date()) - start }