From 5695bfd6453d88d89a29ab8da1ec047e27094e23 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 4 Aug 2019 17:20:45 -0400 Subject: [PATCH] App was throwing error during filmout. Re-wrote the resizing logic so that if it can't find dimensions in the info, don't resize the image. This may lead to squashing, as I've seen in frameloom, but I suspect this problem is with the UI and the superfluous "USE FILE" button. --- app/lib/ffmpeg/index.js | 22 ++++++++++++--------- app/lib/ffmpeg/index.js.map | 2 +- app/package-lock.json | 2 +- cli/lib/ffmpeg/index.js | 22 ++++++++++++--------- cli/lib/ffmpeg/index.js.map | 2 +- lib/ffmpeg/index.js | 22 ++++++++++++--------- lib/ffmpeg/index.js.map | 2 +- package-lock.json | 3 +++ src/ffmpeg/index.ts | 39 +++++++++++++++++++++---------------- 9 files changed, 68 insertions(+), 48 deletions(-) diff --git a/app/lib/ffmpeg/index.js b/app/lib/ffmpeg/index.js index bfb0669..7bd0ba7 100644 --- a/app/lib/ffmpeg/index.js +++ b/app/lib/ffmpeg/index.js @@ -14,11 +14,11 @@ function padded_frame(i) { return str; } async function frame(state, light) { - let frame = state.frame; - let video = state.path; - let w = state.info.width; - let h = state.info.height; - let padded = padded_frame(frame); + const frameNum = state.frame; + const video = state.path; + const w = state.info.width; + const h = state.info.height; + const padded = padded_frame(frameNum); let ext = 'tif'; let rgb = light.color; let tmpoutput; @@ -26,16 +26,20 @@ async function frame(state, light) { let output; let cmd2; let output2; - console.dir(state); + let scale = ''; + if (w && h) { + scale = `,scale=${w}:${h}`; + } + //console.dir(state) //if (system.platform !== 'nix') { ext = 'png'; //} + tmpoutput = path_1.join(TMPDIR, `export-${padded}.${ext}`); rgb = rgb.map((e) => { return parseInt(e); }); - tmpoutput = path_1.join(TMPDIR, `export-${padded}.${ext}`); - //,scale=${w}:${h} - cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frame})'" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`; + // + cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frameNum})'${scale}" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`; cmd2 = `convert "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${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/lib/ffmpeg/index.js.map b/app/lib/ffmpeg/index.js.map index 8172cf2..5b4f1cf 100644 --- a/app/lib/ffmpeg/index.js.map +++ b/app/lib/ffmpeg/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,+BAA4B;AAC5B,uCAA0D;AAC1D,+BAA4B;AAI5B,IAAI,MAAM,GAAS,EAAE,CAAC;AACtB,IAAI,MAAe,CAAC;AAEpB,SAAS,YAAY,CAAE,CAAU;IAChC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACjC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KAChB;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,KAAK,UAAU,KAAK,CAAE,KAAW,EAAE,KAAW;IAC7C,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;IACvB,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAA;IACtB,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAA;IACxB,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAA;IACz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BACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACnB;QACF,CAAC,CAAC,CAAC;KACH;AACF,CAAC;AAED,KAAK,UAAU,QAAQ;IACtB,IAAI,UAAU,CAAC;IACf,IAAI;QACH,UAAU,GAAG,MAAM,iBAAM,CAAC,MAAM,CAAC,CAAC;KAClC;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;KACjD;IAED,IAAI,CAAC,UAAU,EAAE;QAChB,IAAI;YACH,MAAM,gBAAK,CAAC,MAAM,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,EAAE,CAAC,CAAC;SACxC;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;SAC7C;KACD;IACD,IAAI;QACH,MAAM,QAAQ,EAAE,CAAC;KACjB;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,GAAS,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,CAAC;IACb,MAAM,GAAG,WAAI,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAE3C,QAAQ,EAAE,CAAC;IAEX,OAAO;QACN,MAAM;QACN,KAAK;QACL,KAAK;QACL,QAAQ;KACR,CAAA;AACF,CAAC,CAAA"} \ No newline at end of file diff --git a/app/package-lock.json b/app/package-lock.json index b575776..0d39699 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,6 +1,6 @@ { "name": "mcopy-app", - "version": "1.4.16", + "version": "1.4.17", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cli/lib/ffmpeg/index.js b/cli/lib/ffmpeg/index.js index bfb0669..7bd0ba7 100644 --- a/cli/lib/ffmpeg/index.js +++ b/cli/lib/ffmpeg/index.js @@ -14,11 +14,11 @@ function padded_frame(i) { return str; } async function frame(state, light) { - let frame = state.frame; - let video = state.path; - let w = state.info.width; - let h = state.info.height; - let padded = padded_frame(frame); + const frameNum = state.frame; + const video = state.path; + const w = state.info.width; + const h = state.info.height; + const padded = padded_frame(frameNum); let ext = 'tif'; let rgb = light.color; let tmpoutput; @@ -26,16 +26,20 @@ async function frame(state, light) { let output; let cmd2; let output2; - console.dir(state); + let scale = ''; + if (w && h) { + scale = `,scale=${w}:${h}`; + } + //console.dir(state) //if (system.platform !== 'nix') { ext = 'png'; //} + tmpoutput = path_1.join(TMPDIR, `export-${padded}.${ext}`); rgb = rgb.map((e) => { return parseInt(e); }); - tmpoutput = path_1.join(TMPDIR, `export-${padded}.${ext}`); - //,scale=${w}:${h} - cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frame})'" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`; + // + cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frameNum})'${scale}" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`; cmd2 = `convert "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${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/cli/lib/ffmpeg/index.js.map b/cli/lib/ffmpeg/index.js.map index 8172cf2..5b4f1cf 100644 --- a/cli/lib/ffmpeg/index.js.map +++ b/cli/lib/ffmpeg/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,+BAA4B;AAC5B,uCAA0D;AAC1D,+BAA4B;AAI5B,IAAI,MAAM,GAAS,EAAE,CAAC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AO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,GAAS,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,CAAC;IACb,MAAM,GAAG,WAAI,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAE3C,QAAQ,EAAE,CAAC;IAEX,OAAO;QACN,MAAM;QACN,KAAK;QACL,KAAK;QACL,QAAQ;KACR,CAAA;AACF,CAAC,CAAA"} \ No newline at end of file diff --git a/lib/ffmpeg/index.js b/lib/ffmpeg/index.js index bfb0669..7bd0ba7 100644 --- a/lib/ffmpeg/index.js +++ b/lib/ffmpeg/index.js @@ -14,11 +14,11 @@ function padded_frame(i) { return str; } async function frame(state, light) { - let frame = state.frame; - let video = state.path; - let w = state.info.width; - let h = state.info.height; - let padded = padded_frame(frame); + const frameNum = state.frame; + const video = state.path; + const w = state.info.width; + const h = state.info.height; + const padded = padded_frame(frameNum); let ext = 'tif'; let rgb = light.color; let tmpoutput; @@ -26,16 +26,20 @@ async function frame(state, light) { let output; let cmd2; let output2; - console.dir(state); + let scale = ''; + if (w && h) { + scale = `,scale=${w}:${h}`; + } + //console.dir(state) //if (system.platform !== 'nix') { ext = 'png'; //} + tmpoutput = path_1.join(TMPDIR, `export-${padded}.${ext}`); rgb = rgb.map((e) => { return parseInt(e); }); - tmpoutput = path_1.join(TMPDIR, `export-${padded}.${ext}`); - //,scale=${w}:${h} - cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frame})'" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`; + // + cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frameNum})'${scale}" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`; cmd2 = `convert "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${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/lib/ffmpeg/index.js.map b/lib/ffmpeg/index.js.map index 8172cf2..5b4f1cf 100644 --- a/lib/ffmpeg/index.js.map +++ b/lib/ffmpeg/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,+BAA4B;AAC5B,uCAA0D;AAC1D,+BAA4B;AAI5B,IAAI,MAAM,GAAS,EAAE,CAAC;AACtB,IAAI,MAAe,CAAC;AAEpB,SAAS,YAAY,CAAE,CAAU;IAChC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACjC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KAChB;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,KAAK,UAAU,KAAK,CAAE,KAAW,EAAE,KAAW;IAC7C,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;IACvB,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAA;IACtB,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAA;IACxB,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAA;IACzB,IAAI,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;IAChC,IAAI,GAAG,GAAG,KAAK,CAAA;IACf,IAAI,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC;IACtB,IAAI,SAAS,CAAC;IACd,IAAI,GAAG,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BAAM,CAAC,MAAM,CAAC,CAAC;KAClC;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;KACjD;IAED,IAAI,CAAC,UAAU,EAAE;QAChB,IAAI;YACH,MAAM,gBAAK,CAAC,MAAM,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,EAAE,CAAC,CAAC;SACxC;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;SAC7C;KACD;IACD,IAAI;QACH,MAAM,QAAQ,EAAE,CAAC;KACjB;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,GAAS,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,CAAC;IACb,MAAM,GAAG,WAAI,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAE3C,QAAQ,EAAE,CAAC;IAEX,OAAO;QACN,MAAM;QACN,KAAK;QACL,KAAK;QACL,QAAQ;KACR,CAAA;AACF,CAAC,CAAA"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3d3b78f..eb32115 100644 --- a/package-lock.json +++ b/package-lock.json @@ -681,6 +681,9 @@ } } }, + "filmout": { + "version": "file:lib/filmout" + }, "find-replace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", diff --git a/src/ffmpeg/index.ts b/src/ffmpeg/index.ts index 1a1e581..7967f3c 100644 --- a/src/ffmpeg/index.ts +++ b/src/ffmpeg/index.ts @@ -20,32 +20,37 @@ function padded_frame (i : number) { } async function frame (state : any, light : any) { - 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 rgb = light.color; - let tmpoutput; - let cmd; - let output; - let cmd2; - let output2; + const frameNum : number = state.frame + const video : string = state.path + const w : number = state.info.width + const h : number = state.info.height + const padded : string = padded_frame(frameNum) + let ext : string = 'tif' + let rgb : any[] = light.color; + let tmpoutput : string; + let cmd : string; + let output : any; + let cmd2 : string; + let output2 : any; - console.dir(state) + let scale : string = ''; + if (w && h) { + scale = `,scale=${w}:${h}`; + } + + //console.dir(state) //if (system.platform !== 'nix') { ext = 'png'; //} + tmpoutput = join(TMPDIR, `export-${padded}.${ext}`); + rgb = rgb.map((e : string) => { return parseInt(e); }); - - tmpoutput = join(TMPDIR, `export-${padded}.${ext}`); -//,scale=${w}:${h} - cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frame})'" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`; +// + cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frameNum})'${scale}" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`; cmd2 = `convert "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${tmpoutput}"`; //ffmpeg -i "${video}" -ss 00:00:07.000 -vframes 1 "export-${time}.jpg"