1

I have to write a script which continuously checks if a video is present in a particular folder and if it finds any video, it rightaway starts an application and uploads the video to that application.

The application in my case is Turbo Video Stabilizer by muvee I am not sure if this is even possible and if possible I am clueless in what direction I must begin.

Please help me out with advice of any sort as to how to approach this problem.

EDIT

I read about a few ways to check presence of a file in a folder using C# like this and also an example of running an application like this. However I am still not sure how do I actually use the application from my own program. I need to automate even the video in the folder being loaded onto the program. Is there any way to automate this process as well?

Community
  • 1
  • 1
newbie2015
  • 581
  • 5
  • 29

1 Answers1

1

To begin with, your question lacks essential details that are of the essence to answer or suggest you a way to achieve your quest. But few questions before we move forward:

1) What platform will be used to develop this project (Linux/Windows)?

2) Does the application "Turbo Video Stabilizer by muvee" provides any API interface to upload and run the video?

3) How many videos are going to be monitored? Is it a single file with fixed name, or any file? Your question says a video file, so I assume it is just one file.

4) How often should monitoring and uploading take place ?

Just to get you start: I will be suggesting ways based on Linux operating system. The concept won't differ much for Windows, but may need some different means. One more assumption, the application will upload one video file.

1) File monitoring script in bash: Look for "temp.mp4" file in a folder called /download (for example). If present, call the API interface of the ""Turbo Video Stabilizer by muvee" for uploading it.

Just a template:

#!/bin/bash

for file in /download/*
do
    if [ ! -f "${file% temp.mp4} temp.mp4" ]; then
        echo "--temp.mp4 detected "

    #Call the uploading API and store the return code
    res=upload.sh

    if [ $res -e 0 ];then 
        echo "--Uploading successful" 
    else 
        echo "--Uploading failed"
    fi

done

2) Continuous Monitoring: Make a cronjob in linux for configurable number of minutes as desired by you to trigger the File Monitoring script. We can also make the File Monitoring script go in infinite loop and make it sleep in between, but as I said above, your question lacks that information.

*/5 * * * * /usr/local/fileMonitoring.sh (for example)

3) API: This is the central part to your project. If uploading is required, then there should be possible mean to achieve so. The mechanics of how this will be done will further guide the development of your application as a whole.

Remember, there are many ways to go about this. Sometimes, people sync dropbox folder with the App, so that any changes made to the folder is seen by the application, and there is no need to monitor using a script, only uploading script needs to be initiated.

I hope this helps you at least to think in the right direction.

Thomas Erker
  • 358
  • 1
  • 9
Gaurav Sharma
  • 166
  • 10
  • Thank you for the in depth answer. Now to answer your questions: I will be using Windows platform to develop this project. And no, Turbo Video Stabilizer does not provide any API to control the video uploading or other controls. Not to my knowledge from as much I searched. This process needs to be running in the background all the time. And new videos will be uploaded in a specific folder only. And once the video is uploaded the process needs to begin right away. – newbie2015 Sep 04 '15 at 19:09
  • 1
    Asking out of curiosity: could you not also do this with `watch` instead of a cron job? – Ashelyn Dawn Sep 05 '15 at 00:47
  • @PawnStar Yes, watch will also work. I just gave a template to start with :) – Gaurav Sharma Sep 05 '15 at 13:51