Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Research and Development of "Delir" at Nov, 2016

Hanakla
November 27, 2016

Research and Development of "Delir" at Nov, 2016

開発中のVFXアプリ "Delir"について、社内勉強会で話したものに補足したりしたもの

Hanakla

November 27, 2016
Tweet

More Decks by Hanakla

Other Decks in Programming

Transcript

  1. ͍·ͷͱ͜Ζͷ໨ඪ w શମ
 ΫϩεϓϥοτϑΥʔϜରԠ͍ͨ͠ w ϨϯμϦϯάج൫ʢө૾ͷॻ͖ग़͠ʣ
 ΞϧϑΝ෇͖ಈըͷॻ͖ग़͠Λαϙʔτ͍ͨ͠
 ɹʢϝΠϯฤूʹ࢖͑ͳͯ͘΋ɺ෦෼తͳૉࡐө૾࡞Δͷʹ࢖͑Δ͘Β͍ʹ͸͍ͨ͠ʣ w ϓϥάΠϯج൫


    ϢʔβʔϝΠυͷϓϥάΠϯΛ࢖͑ΔΑ͏ʹ͍ͨ͠ʢ഑෍ͱ͔Ͱ͖ΔΑ͏ʹʣ
 ̍࡞඼ઐ༻ʹؾܰʹॻ͖ࣺͯͰ͖ΔεΫϦϓςΟϯάΛͰ͖ΔΑ͏ʹ͍ͨ͠
 8FC(-ɾ8FC"VEJPɾ$BOWBT͋ͨΓΛ࢖͑ΔΑ͏ʹ͍ͨ͠ w ϑϩϯτΤϯυʢ6*ʣ
 ͳΜ͔Α͠ͳʹোΓͳ͍͘Β͍ʹ͍ͨ͠
  2. ͰɺਐḿͲ͏Ͱ͔͢ʁ w શମ
 ɾ·ͩ։ൃػͷNBD04Ͱ͔͠ಈ͔ͯ͠ͳ͍ w ϨϯμϦϯάج൫ʢө૾ͷॻ͖ग़͠ʣ
 ɾͱΓ͋͑ͣNQॻ͖ग़͠͸Ͱ͖Δ͕ɺ։ൃ؀ڥͷNBD04Ͱ͔͠ಈ࡞֬ೝ͕औΕͯͳ͍
 ɾͨΊ͠ʹ6U7JEFPͰग़ྗͨ͠Βಁաͷॻ͖ग़͠΋ग़དྷ֮ͨ͑ʢ͏Ζ֮͑ʣ w ϓϥάΠϯج൫


    ɾϓϥάΠϯ͕zԿ͔zΛϨϯμϦϯά͢Δ·Ͱͷ࢓૊Έ͸Ͱ͖ͯΔ
 ɹɾ"&ͷΑ͏ͳϓϨϏϡʔը໘্Ͱ഑ஔΛม͑ͨΓ͢Δ࢓૊Έ͸શ͘ग़དྷͯͳ͍ʢߟ͑ͯΔʣ
 ɾॻ͖ࣺͯεΫϦϓςΟϯάͷ࢓૊Έ͸΅Μ΍Γߟ͑ͯΔ࠷த
 ɾඪ४ػೳΛϓϥάΠϯͱ࣮ͯ͠૷͠ͳ͕Βςετͯ͠Δ
 ɹɾ)5.-7JEFPʹΑΔಈըϑΝΠϧͷಡΈࠐΈ͸Ͱ͖Δ
 ɹɾBVSPSBKTʹΑΔԻ੠ͷσίʔυͱಉ࣌̍ԻݯͷԻ੠ॻ͖ग़͠͸Ͱ͖ͯΔʢΫιβίʣ w ϑϩϯτΤϯυ
 ɾΨόΨόϦςΟ͕ߴ͍
  3. ࠓճ͸͜͜ͷ࿩Λ͠·͢ w 1MBUGPSN
 &MFDUSPO w 'SPOU&OE
 )5.-+BWB4DSJQU$44 w #BDLFOE 1MVHJO3FOEFSJOHTZTUFN

    
 +BWB4DSJQU/PEFKT$  ·ͩೖΕͯͳ͍͚Ͳʣ w &ODPEFS
 ⒎NQFH ͞ΘΓ͚ͩ࿩͢
  4. import fs from "fs" import {spawn} from "child_process" import canvasToBuffer

    from 'electron-canvas-to-buffer' window.addEventListener('DOMContentLoaded', () => { const FRAMERATE = 30 const VIDEO_DURATION_SEC = 30 const OUTPUT_FRAMES = VIDEO_DURATION_SEC * 30 const cRand = () => ((Math.random() * 256) | 0).toString(16) const canvas = document.querySelector(‘#canvas’) Object.assign(canvas, {width: 640, height: 360}) const ctx = canvas.getContext('2d') const encoder = spawn('ffmpeg', `-i pipe:0 -framerate ${FRAMERATE} -c:v png_pipe -c:v libx264 -r ${OUTPUT_FRAMES} -s 640x360 test.mp4`.split(' ')) for (let i = 0; i < OUTPUT_FRAMES i++) { ctx.fillStyle = '#' + [cRand(), cRand(), cRand()].join('') ctx.fillRect(0, 0, 640, 360) let buffer = canvasToBuffer(canvas, 'image/png') encoder.stdin.write(buffer) } encoder.stdin.end() })
  5. ͔͠͠ʜ w σίʔυॏ͍ɾ஗͍
 ͨͩͷ࠶ੜͳΒ໰୊ͳ͍͚Ͳ
 ೚ҙͷϑϨʔϜ΁γʔΫ͠ଓ͚ΔͱGQT͘Β͍Ͱਫ਼Ұഋ
 WJEFPλάΑΓԼͷϨΠϠʔ͸ωΠςΟϒ͔ͩΒ࠷దԽͷ༨஍΋ͳ͍ʜ w ରԠܗࣜগͳ͍ʢʂʣ
 ɾNQ )

    8FC. PHWˠෆՄٯ )͸Մٯ΋Ͱ͖ΔͬΆ͍͚Ͳʜʣ
 ɾ"MQIB෇͖ͷܗࣜ͸αϙʔτ͞Εͯͳ͍
 ɹʢΫϩϚΩʔ͢Ε͹ͱ͔ͦ͏͍͏࿩͡Όͳ͍ɺ"MQIB෇͖ಈը͕࢖͍͍ͨʣ w Ͳͦ͜͜ͷϒϩάͰࢄʑॻ͖ࣺͯΒΕͨํ๏Ͱͭ·Βͳ͍
  6. ͜Ε ЋΛϑΥʔΫͨ͠΋ͷΛ࿔ͬͯ ετϦʔϜϦʔυग़དྷΔΑ͏ʹ͢Δ ྲྀΕ w +4͔Βಡ·͍ͤͨϑΝΠϧͷύεΛ౉͢ w MJCBWDPEFDʹಈըϑΝΠϧΛ৯ΘͤΔ w $

    ্Ͱ̍ϑϨʔϜΛ3(#"഑ྻʹσίʔυ͢Δ w ϑϨʔϜ͕औΕͨΒ"SSBZ#V⒎FSʹͯ͠+4ͷੈքʹؼ͢ w "SSBZ#V⒎FSΛ*NBHF%BUBʹίϐʔͯ͠$BOWBTʹు͔ͤΔ
  7. 0⒎TDSFFO$BOWBT$POUFYU w $BOWBT$POUFYU͕ผεϨουʹసૹͰ͖ΔΑ͏ ʹͳͬͨ
 %$POUFYU 8FC(-͕ผεϨουͰಈ͔ͤΔΑ͏ʹͳͬͨ w ొ৔ҎલͰ΋*NBHF%BUB "SSBZ#V⒎FS ΛసૹͰ͖͚ͨͲ


    8PSLFSεϨου಺Ͱ$BOWBT"1*͕શ͘࢖͑ͳ͔ͬͨͷͰɺ
 ϐΫηϧ୯ҐͰσʔλΛมߋ͢Δ͔͠ͳ࣮͘༻త͡Όͳ͔ͬͨ w SFRVFTU"OJNBUJPO'SBNFͳͲ͸8PSLFSεϨου্ʹͳ͍ͷͰ
 ϝΠϯεϨουͱΑ͠ͳʹಉظΛͱΔ