Programming/node.js2018. 9. 11. 15:03

한줄 요약

ffmpeg 패키지가 node.js의 패키지가 아닌 실제 바이너리를 의미함.. -_-

윈도우건 리눅스건 상관없는데, node-rtsp-stream 문제가 있는 것으로 보임


---

패키지 까는데 윈도우에서 하고 있어서 열심히 에러 뿜뿜 해주심 -_-


C:\> npm install -g node-rtsp-stream

npm WARN notice [SECURITY] ws has the following vulnerabilities: 2 high, 1 low. Go here for more details: https://nodesecurity.io/advisories?search=ws&version=0.4.32 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.


> ws@0.4.32 install C:\Users\user\AppData\Roaming\npm\node_modules\node-rtsp-stream\node_modules\ws

> (node-gyp rebuild 2> builderror.log) || (exit 0)



C:\Users\user\AppData\Roaming\npm\node_modules\node-rtsp-stream\node_modules\ws>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )

이 솔루션의 프로젝트를 한 번에 하나씩 빌드합니다. 병렬 빌드를 사용하려면 "/m" 스위치를 추가하십시오.

MSBUILD : error MSB3428: Visual C++ 구성 요소 "VCBuild.exe"을(를) 로드할 수 없습니다. 이 문제를 해결하려면 1) .NET Framework 2.0 SDK를 설치하거나, 2

) Microsoft Visual Studio 2005를 설치하거나, 3) 해당 구성 요소가 다른 위치에 설치되어 있는 경우에는 그 위치를 시스템 경 로에 추가하십시오.  [C:\Users\user\AppDa

ta\Roaming\npm\node_modules\node-rtsp-stream\node_modules\ws\build\binding.sln]

MSBUILD : error MSB3428: Visual C++ 구성 요소 "VCBuild.exe"을(를) 로드할 수 없습니다. 이 문제를 해결하려면 1) .NET Framework 2.0 SDK를 설치하거나, 2

) Microsoft Visual Studio 2005를 설치하거나, 3) 해당 구성 요소가 다른 위치에 설치되어 있는 경우에는 그 위치를 시스템 경 로에 추가하십시오.  [C:\Users\user\AppDa

ta\Roaming\npm\node_modules\node-rtsp-stream\node_modules\ws\build\binding.sln]

+ node-rtsp-stream@0.0.3

added 6 packages in 21.052s

[링크 : https://www.npmjs.com/package/node-rtsp-stream]


걍 깔았더니 또 에러 뿜뿜해주심

C:\>npm install -g windows-build-tools


> windows-build-tools@4.0.0 postinstall C:\Users\user\AppData\Roaming\npm\node_modules\windows-build-tools

> node ./dist/index.js




Downloading BuildTools_Full.exe

[============================================>] 100.0% of 3.29 MB (3.29 MB/s)

Downloaded BuildTools_Full.exe. Saved to C:\Users\user\.windows-build-tools\BuildTools_Full.exe.


Starting installation...

Please restart this script from an administrative PowerShell!

The build tools cannot be installed without administrative rights.

To fix, right-click on PowerShell and run "as Administrator".

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! windows-build-tools@4.0.0 postinstall: `node ./dist/index.js`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the windows-build-tools@4.0.0 postinstall script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2018-09-11T05_51_43_564Z-debug.log 

[링크 : https://superuser.com/questions/1032689/how-do-i-add-vcbuild-exe-to-windows-10-w-o-visual-studio]


C:\>npm install -g windows-build-tools


> windows-build-tools@4.0.0 postinstall C:\Users\user\AppData\Roaming\npm\node_modules\windows-build-tools

> node ./dist/index.js




Downloading BuildTools_Full.exe

[>                                            ] 0.0% (0 B/s)

Downloaded BuildTools_Full.exe. Saved to C:\Users\user\.windows-build-tools\BuildTools_Full.exe.


Starting installation...

Launched installers, now waiting for them to finish.

This will likely take some time - please be patient!


Status from the installers:

---------- Visual Studio Build Tools ----------

Successfully installed Visual Studio Build Tools.

------------------- Python --------------------

Python 2.7.15 is already installed, not installing again.


Now configuring the Visual Studio Build Tools..


All done!


+ windows-build-tools@4.0.0

added 142 packages in 102.328s 


영안되는거 같아서 삭제하고 다시 까는데 또 안되는 느낌 -_-

C:\>npm install -g node-rtsp-stream


> ws@0.4.32 install C:\Users\user\AppData\Roaming\npm\node_modules\node-rtsp-stream\node_modules\ws

> (node-gyp rebuild 2> builderror.log) || (exit 0)



C:\Users\user\AppData\Roaming\npm\node_modules\node-rtsp-stream\node_modules\ws>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )

이 솔루션의 프로젝트를 한 번에 하나씩 빌드합니다. 병렬 빌드를 사용하려면 "/m" 스위치를 추가하십시오.

C:\Users\user\AppData\Roaming\npm\node_modules\node-rtsp-stream\node_modules\ws\build\bufferutil.vcxproj(20,3): err

or MSB4019: 가져온 "C:\Microsoft.Cpp.Default.props" 프로젝트를 찾을 수 없습니다. <Import> 선언에 지정한 경로가 올바른지 그리고 파일이 디스크에 있는지 확인하십시오.

C:\Users\user\AppData\Roaming\npm\node_modules\node-rtsp-stream\node_modules\ws\build\validation.vcxproj(20,3): err

or MSB4019: 가져온 "C:\Microsoft.Cpp.Default.props" 프로젝트를 찾을 수 없습니다. <Import> 선언에 지정한 경로가 올바른지 그리고 파일이 디스크에 있는지 확인하십시오.

+ node-rtsp-stream@0.0.3

added 6 packages in 5.346s 


췟.. 모듈 인식을 못한다.

C:\tt>node app.js

module.js:549

    throw err;

    ^


Error: Cannot find module 'node-rtsp-stream'

    at Function.Module._resolveFilename (module.js:547:15)

    at Function.Module._load (module.js:474:25)

    at Module.require (module.js:596:17)

    at require (internal/module.js:11:18)

    at Object.<anonymous> (C:\Users\classact\Desktop\tt\app.js:1:72)

    at Module._compile (module.js:652:30)

    at Object.Module._extensions..js (module.js:663:10)

    at Module.load (module.js:565:32)

    at tryModuleLoad (module.js:505:12)

    at Function.Module._load (module.js:497:3) 


영 안되는 기분인데.. 

아무튼 우리의 친구 VLC를 깔고

만만한(?) 동영상 하나 받고

[링크 : https://archive.org/download/BigBuckBunny]


중요 : ffmpeg 실행파일이 필요하므로 적절한 위치에 압축풀고 윈도우 경로를 지정해준다.

[링크 : https://ffmpeg.zeranoe.com/builds/]


클라이언트에는 이거 하나 더 추가해주고

var WebSocket = require('ws') 

client = new Websocket('ws://localhost:9999');

player = new jsmpeg(client, {

    canvas: canvas // Canvas should be a canvas DOM element

});

[링크 : https://stackoverflow.com/questions/21441867/referenceerror-websocket-is-not-defined]


아놔.. window is not defined -_- 아 몰라 배째 


---

아 몰라 머리아프네 ㅠㅠ


[링크 : https://github.com/phoboslab/jsmpeg]

[링크 : https://jsmpeg.com/]

[링크 : https://www.npmjs.com/package/node-rtsp-stream]

[링크 : https://www.npmjs.com/package/jsmpeg]

[링크 : https://phoboslab.org/log/2013/05/mpeg1-video-decoder-in-javascript]

[링크 : https://github.com/Wifsimster/node-rtsp-stream-es6] <<

[링크 : https://github.com/phoboslab/jsmpeg/blob/master/view-stream.html]

'Programming > node.js' 카테고리의 다른 글

node-rtsp-stream 사용  (2) 2018.09.12
node.js 글로벌 모듈 목록보기  (0) 2018.09.11
node.js HTTP 요청하기  (0) 2018.09.10
cURL 그리고 REST  (6) 2018.09.09
node.js rtsp 스트리밍  (0) 2018.09.07
Posted by 구차니
Programming/node.js2018. 9. 10. 14:58

node.js 에서 다른 REST 서버로 요청하는걸 찾는중


option의 type을 지정하는거군..


[링크 : http://devnauts.tistory.com/95]

[링크 : http://shiya.io/send-http-requests-to-a-server-with-node-js/]

'Programming > node.js' 카테고리의 다른 글

node.js 글로벌 모듈 목록보기  (0) 2018.09.11
node-rtsp-stream 윈도우에서 설치하기는 실패?  (0) 2018.09.11
cURL 그리고 REST  (6) 2018.09.09
node.js rtsp 스트리밍  (0) 2018.09.07
RESTful  (0) 2018.09.07
Posted by 구차니
Programming/node.js2018. 9. 9. 19:40

"node.js 인 액션" 책 보다가 검색

cURL에서 -X 옵션을 주면 된다


$ curl -X GET http://127.0.0.1:3000/api/users/bakyeono

$ curl -X POST http://127.0.0.1:3000/api/languages/ansi-common-lisp

$ curl -X PUT http://127.0.0.1:3000/api/resources/1789 

[링크 : https://bakyeono.net/post/2016-05-02-rest-api-client-for-cli.html]



-X/--request <command>

(HTTP) Specifies a custom request method to use when communicating with the HTTP server. The specified request will be used instead of the method otherwise used (which defaults to GET). Read the HTTP 1.1 specification for details and explanations. Common additional HTTP requests include PUT and DELETE, but related technologies like WebDAV offers PROPFIND, COPY, MOVE and more.

(FTP) Specifies a custom FTP command to use instead of LIST when doing file lists with FTP.


If this option is used several times, the last one will be used.

[링크 : https://linux.die.net/man/1/curl]



'Programming > node.js' 카테고리의 다른 글

node-rtsp-stream 윈도우에서 설치하기는 실패?  (0) 2018.09.11
node.js HTTP 요청하기  (0) 2018.09.10
node.js rtsp 스트리밍  (0) 2018.09.07
RESTful  (0) 2018.09.07
node.js jwt -JSON Web Token  (0) 2018.09.07
Posted by 구차니
Programming/node.js2018. 9. 7. 16:24

찾아보는데.. ffmpeg을 통해서 로컬에서 변환해서 전송해주는 방식

그러면.. 타임스탬프를 받을 수 있으려나?


[링크 : https://github.com/phoboslab/jsmpeg]

[링크 : https://www.npmjs.com/package/rtsp-ffmpeg]

[링크 : https://www.npmjs.com/package/node-rtsp-stream]

'Programming > node.js' 카테고리의 다른 글

node.js HTTP 요청하기  (0) 2018.09.10
cURL 그리고 REST  (6) 2018.09.09
RESTful  (0) 2018.09.07
node.js jwt -JSON Web Token  (0) 2018.09.07
아직 쓸일은 없지만 걍 찾아본 node.js ssl 적용  (0) 2018.09.07
Posted by 구차니
Programming/node.js2018. 9. 7. 15:40

URI나 CRUD 등의 개념이 나오는데

서버에 대해서 하나의 주소 경로로 하여 명사형으로 URI를 구성하고

GET/PUT/POST/DELETE HTTP 메소드를 이용하여

DB의 create/read(select)/update/delete를 구현한다는 것 정도로 일단 이해


[링크 : https://nesoy.github.io/articles/2017-02/REST]

[링크 : https://spoqa.github.io/2013/06/11/more-restful-interface.html]

[링크 : http://blog.remotty.com/blog/2014/01/28/lets-study-rest/]

[링크 : https://beyondj2ee.wordpress.com/2013/03/21/당신의-api가-restful-하지-않은-5가지-증거/]

'Programming > node.js' 카테고리의 다른 글

cURL 그리고 REST  (6) 2018.09.09
node.js rtsp 스트리밍  (0) 2018.09.07
node.js jwt -JSON Web Token  (0) 2018.09.07
아직 쓸일은 없지만 걍 찾아본 node.js ssl 적용  (0) 2018.09.07
node.js exec와 JSON.parse()  (0) 2018.09.07
Posted by 구차니
Programming/node.js2018. 9. 7. 15:19
Programming/node.js2018. 9. 7. 13:44

부디(?) 이걸 쓸일이 아직 안생기길..


[링크 : https://www.securesign.kr/guides/Node-js-SSL-Certificates-Install]

'Programming > node.js' 카테고리의 다른 글

RESTful  (0) 2018.09.07
node.js jwt -JSON Web Token  (0) 2018.09.07
node.js exec와 JSON.parse()  (0) 2018.09.07
node.js express template  (0) 2018.09.06
node.js exec()  (0) 2018.09.06
Posted by 구차니
Programming/node.js2018. 9. 7. 10:53

test.js

var exec = require('child_process').exec,

child;


child = exec("type test.txt", function(error, stdout, stderr)

{

console.log(stdout);

var obj = JSON.parse(stdout);

console.log(obj.name);

if(error !== null)

{

console.log(error);

}

}); 


test.txt

{

    "name": "식빵",

    "family": "웰시코기",

    "age": 1,

    "weight": 2.14

}


결과.. 으으 인코딩 건드리기 싫다...

아무튼 type으로 파일 내용 돌려받고(즉, 아무 명령어나 실행하고 그 결과를 받아)

JSON 포맷일 경우 파싱해서 사용가능한걸 실증!

D:\node_test>node test.js

{

    "name": "�Ļ�",

    "family": "�����ڱ�",

    "age": 1,

    "weight": 2.14

}

�Ļ� 


[링크 : http://tcpschool.com/json/json_basic_structure]

[링크 : https://www.w3schools.com/js/js_json_parse.asp]

'Programming > node.js' 카테고리의 다른 글

node.js jwt -JSON Web Token  (0) 2018.09.07
아직 쓸일은 없지만 걍 찾아본 node.js ssl 적용  (0) 2018.09.07
node.js express template  (0) 2018.09.06
node.js exec()  (0) 2018.09.06
node.js / express/ pug(jade) 문법  (0) 2018.09.05
Posted by 구차니
Programming/node.js2018. 9. 6. 18:54

기본 템플릿은 express-generator를 통해서 만들면 되긴 하는데


C:\> npm install -g express-generator

...

+ express-generator@4.16.0

added 10 packages in 2.2s


C:\>express --ejs


  warning: option `--ejs' has been renamed to `--view=ejs'



   create : public\

   create : public\javascripts\

   create : public\images\

   create : public\stylesheets\

   create : public\stylesheets\style.css

   create : routes\

   create : routes\index.js

   create : routes\users.js

   create : views\

   create : views\error.ejs

   create : views\index.ejs

   create : app.js

   create : package.json

   create : bin\

   create : bin\www


   install dependencies:

     > npm install


   run the app:

     > SET DEBUG=node-test:* & npm start


[링크  : http://pyrasis.com/nodejs/nodejs-HOWTO]

[링크  : https://www.npmjs.com/package/express-generator]


-g는 global의 g

[링크 : http://someoneofsunrin.tistory.com/59]



app.js 에 ejs를 기본으로 삼아서 불편할 수도 있다.

// view engine setup

app.set('views', path.join(__dirname, 'views'));

app.set('view engine', 'ejs');


어쩌다 보니(?) pug를 먼저 써서
pug를 쓰려면 조금 수정을 해주어야 한다.


아무튼.. 기본 적인 소스 틀 만들기에는 express-generator가 무난해 보인다.



+

2018.09.11


$ express --view=pug myapp 

[링크 : http://expressjs.com/ko/starter/generator.html]

'Programming > node.js' 카테고리의 다른 글

아직 쓸일은 없지만 걍 찾아본 node.js ssl 적용  (0) 2018.09.07
node.js exec와 JSON.parse()  (0) 2018.09.07
node.js exec()  (0) 2018.09.06
node.js / express/ pug(jade) 문법  (0) 2018.09.05
npm package.json  (0) 2018.09.05
Posted by 구차니
Programming/node.js2018. 9. 6. 18:45

js 라고는 해도 서버사이드로 확장되면서 서버에서는 당연히(?) 있어야 할 exec()가 추가되었다.

아무튼 exec()로 나오는 결과를 받아서 먼가 처리하는 것 까지는 해봐야 할 듯..


[링크 : https://blog.outsider.ne.kr/551]

[링크 : https://mylko72.gitbooks.io/node-js/content/chapter9/chapter9_2.html]

[링크 : https://nodejs.org/api/child_process.html]


+

2018.09.07

var exec = require('child_process').exec,

child;


child = exec("dir", function(error, stdout, stderr)

{

console.log(stdout);

if(error !== null)

{

console.log(error);

}

});


D:\node_test>node test.js

 D ����̺��� ����: �� ����

 ���� �Ϸ� ��ȣ: CCEE-4FEA


 D:\node_test ���͸�


2018-09-07  ���� 10:38    <DIR>          .

2018-09-07  ���� 10:38    <DIR>          ..

2018-09-07  ���� 10:35               195 test.js

2018-09-07  ���� 10:38                 0 test.txt

2018-09-07  ���� 10:38                 0 �� �ؽ�Ʈ ����.txt

               3�� ����                 195 ����Ʈ

               2�� ���͸�  916,882,796,544 ����Ʈ ���� 


윈도우에서 euc-kr로 받아서 그런가.. 옵션에 euc-kr encoding 해주어도 깨지는건 여전하네..

어짜피 영어로 주고 받을테니 일단 패스~ ㅠㅠ

[링크 : https://junistory.blogspot.com/2017/08/blog-post_24.html]


+

파일이 ANSI라서 보는데 이런식으로 인코딩 바꾸니 

 hild = exec("type test.txt", {encoding: 'ansi'}, function(error, stdout, stderr)


배쨴다 ㅠㅠ

D:\node_test>node test.js

<Buffer 7b 0d 0a 20 20 20 20 22 6e 61 6d 65 22 3a 20 22 bd c4 bb a7 22 2c 0d 0a 20 20 20 20 22 66 61 6d 69 6c 79 22 3a 20 22 c0 a3 bd c3 c4 da b1 e2 22 2c 0d ... > 


'Programming > node.js' 카테고리의 다른 글

node.js exec와 JSON.parse()  (0) 2018.09.07
node.js express template  (0) 2018.09.06
node.js / express/ pug(jade) 문법  (0) 2018.09.05
npm package.json  (0) 2018.09.05
nodaemon  (0) 2018.09.04
Posted by 구차니