Scale frame export to video's advertized size

This commit is contained in:
mmcw-dev 2019-02-10 14:07:07 -05:00
parent b6a6b8a81e
commit 3493759998
2 changed files with 20 additions and 16 deletions

View File

@ -20,20 +20,24 @@ function padded_frame (i) {
return str; return str;
} }
async function frame (video, frame, obj) { async function frame (state) {
let padded = padded_frame(frame); let frame = state.frame
let ext = 'tif'; let video = state.path
let tmpoutput; let w = state.info.width
let cmd; let h = state.info.height
let output; let padded = padded_frame(frame)
let ext = 'tif'
let tmpoutput
let cmd
let output
if (system.platform !== 'nix') { if (system.platform !== 'nix') {
ext = 'png'; ext = 'png'
} }
tmpoutput = path.join(TMPDIR, `export-${padded}.${ext}`) 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}" -ss 00:00:07.000 -vframes 1 "export-${time}.jpg"
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "export-%05d.tiff" //ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "export-%05d.tiff"

View File

@ -554,23 +554,23 @@ dig.move = async function () {
if (last > 0) { if (last > 0) {
display.end() display.end()
//wipe last frame
try {
await ffmpeg.clear(last)
} catch (err) {
console.error(err)
}
} }
try { 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) { } catch (err) {
console.error(err) console.error(err)
} }
display.start(dig.state.frame) display.start(dig.state.frame)
await delay(100) await delay(600)
return (+new Date()) - start return (+new Date()) - start
} }