Skip to main content
micheledauria
Participating Frequently
November 23, 2018
Answered

Manage the socket to upload video

  • November 23, 2018
  • 3 replies
  • 1233 views

Hello everyone.

I would like to know if someone can use the Socket Object to load medium files on a remote server (for example a 10Mb video).

Currently my script manages an FTP connection (passive mode), and through the Socket.write loads files on the server. It works.

The problem is that it is not possible to handle some cases that may occur, such as knowing when the connection has fallen while uploading. Once the socket has started loading, it does not respond to any call, taking up 100% of the CPU. The only stop he encounters is his timeout property.

If the connection drops, and we have a 120sec timeout, the loop continues to run, blocking AfterEffect for two minutes. Any other function is frozen even though there is no more connection. The same AfterEffects does not respond.

Possible solutions to better manage the Socket during an upload?

Thank you.

// Socket

FTP_PASSIVE.encoding = "BINARY";

FTP_PASSIVE.timeout = 120;

// Bytes

video_to_upload.open("r");

video_to_upload.encoding = "BINARY";

DATA =  video_to_upload.read(video_filesize);

video_to_upload.close();

// Upload

FTP_PASSIVE.write( DATA );

FTP_PASSIVE.close();

This topic has been closed for replies.
Correct answer Arie Stavchansky

To answer your question: yes the cURL call can be done in the background, silently, but then it becomes an asynchronous process and is "detached from" or "independent from" the main After Effects thread.  So, if the upload needs to happen before something else needs to happen in AE, then you'll still have to wait for the upload to complete. 

On macOS, you would need to use systems.callSystem() method to invoke an `osascript` call to an AppleScript that launced the cURL call asynchronously.  With VBScript, you can do this by using the WScript object to create a new, separate command prompt that you can invoke the code to upload the video.

Hope this helps!

—Arie

3 replies

micheledauria
Participating Frequently
November 26, 2018

Thank you

Arie StavchanskyCorrect answer
Legend
November 25, 2018

To answer your question: yes the cURL call can be done in the background, silently, but then it becomes an asynchronous process and is "detached from" or "independent from" the main After Effects thread.  So, if the upload needs to happen before something else needs to happen in AE, then you'll still have to wait for the upload to complete. 

On macOS, you would need to use systems.callSystem() method to invoke an `osascript` call to an AppleScript that launced the cURL call asynchronously.  With VBScript, you can do this by using the WScript object to create a new, separate command prompt that you can invoke the code to upload the video.

Hope this helps!

—Arie

Legend
November 24, 2018

Hi There,

Using sockets with ExtendScript is quite slow and you cannot take advantage of SSL with Adobe's implementation of Sockets for AE.  My suggestion is to use the system.callSystem() function that allows you to call commands as if you were at the system's terminal.  In your case, you might use the cURL command on a macOS, and a VBScript on Windows to handle uploads.  Using this method, you have an opportunity to handle all transfers asynchronously, too.

Check out this old thread on the topic:

https://forums.adobe.com/message/5685925#5685925#5685925

With cURL you can also transfer binary files, just need to get the flags right.

Hope this helps provide some direction!

Best,

Arie

micheledauria
Participating Frequently
November 25, 2018

Hi Arie. Thanks for this tip, the system.callSystem() function is really interesting.

Currently I manage an entire FTP process through the socket. I have no connection problems, except to handle errors during the upload. I'd like to write an external engine just for uploading, one for MAC and one for PC. I could provide all the parameters, connection port, files, url, and wait for an answer.

My question is, this process can be done in the background silently, without engaging the whole CPU as happens with the Socket, and without having to install anything? Since you've already faced the problem many years ago, I'd like your help.

Thank you so much.