2

Background to this problem:

I am using FFmpeg to convert videos - it is working fine. I am sending the FFmpeg requests to the command line using exec() in PHP. I am also using node.js and socket.io to deliver real time updates to my users- this is also working fine. I would like to be able to send a real time alert when the video has completed its conversion.

My question is:

How do I send a request from the command line to my node server. Can I run a JS file from the command line? If not what is the best way round it?

Thank you for your advice,

Chris.

0

3 Answers 3

2

I would go for curl. Trigger node with curl.

Something like:

curl localhost:3000/encodingCompleted?user=abc&secret=aWy7@

And now node knows "completed" and can send a realtime update back to the user.

Sign up to request clarification or add additional context in comments.

5 Comments

Is that calling a php page? I get this error using curl "curl: (3) <url> malformed". Any ideas?
No it should call node. curl <yourNodeServer>:<nodePort>/path
Du You know in php when the video is done? Will the external-process return to php?
Hi, yeah, I can call php to update db etc but cannot run a js function from within it.
Yes not direct - but indirect. Forget about the curl. It's not necessary in your case. I'll add a new Answer to you question.
1

In your case: It makes more sense to call node directly via an url from php instead from the command line.

You can trigger node with an url:

  1. Add a function to your node like "videoEncDone(user)" and bind it to a path like "yournodeserver.de/videoEncDone"

  2. After the encoding/converting has finished, call from php (eg. with fopen) the url plus add all necessary information within the query part of that request.

  3. That's it :) - After the url got called, you have all informations (from the url) in node and can talk to the users browser from node

5 Comments

ah and for security reasons you should a secret word to the query :)
Ni Nivoc, thank you for the reply. How do I talk to the client's browser from within node?
How do you retrieve the variables sent from the js page?
pagewil: What do you mean with js page? You can transfer variable contents as part of the url that you call from e.g. php like ?var1=123&var2=345
Christopher: I thought that you use node already to deliver realtime updates to the browsers client. "I am also using node.js and socket.io to deliver real time updates to my users"
0

For command line JS, you can download the sources for the Mozilla or Chrome javascript engines and build them yourself.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.