Repository navigation
How to use?
This solution consists of two parts: for Linux OS and for Windows OS.
Linux part of the solution is responsible for downloading and converting video files to thumbnails.
To run the script we need to pass several options for it.
Script accepts two options:
-
URL address of videostream/file (which must begins with
http://orhttps://and ends with.mp4file extension); -
Video encoder name (
ffmpegoravconv). Note, that this option is optional.
If it's not specified, FFmpeg encoder will be used by default.
So full launch string can be look like this (fetching file using http link, avconv encoder will be used):
sudo /home/ubdm/linux/process_video.sh http://<path to video file>/<file name>.mp4 avconv.
Short version of this string can be like (fetching file using https link, ffmpeg encoder using by default):
sudo /home/ubdm/linux/process_video.sh https://<path to video file>/<file name>.mp4.
Script will create several directories near itself:
-
log– directory containing log files named likeYYYY-MM-DD_proc-video.log, where:- YYYY – year, when script was launched, 4 digits;
- MM – month (01 .. 12), when script was launched, 2 digits;
- DD – day (01 .. 31), when script was launched, 2 digits.
-
scr– directory with subdirectories, named likeYYYY-MM-DD, which contains thumbnail files with naming patternYYYY-MM-DD_HH.NN_SS.jpg, where:- HH – hour (00 .. 23), when video file was fetched, 2 digits;
- NN – minute (00 .. 59), when video file was fetched, 2 digits;
- SS – seconds (05, 15 .. 55 by default) of video file content, 2 digits.
-
tmp– directory for temporary files, which will be deleted after processing (here is stored received video file) with naming patternYYYY-MM-DD_HH.NN.mp4.
Cron tasks can be set as for current user, as for root user or any other, which you will choose.
Please note, that there listed only common commands for basic understanding.
For more information please refer to crontab manual (by using man crontab command).
Please note, if we need to add sheduled tasks for root user (executing script as super user), we must add sudo before each command, listed there.
For adding task to crontab we must execute following command: crontab -e.
After that we will got into crontab document. Go to the end and add script launch line in format like this:
MAILTO=""
*/10 08-18 * * * /home/ubdm/linux/process_video.sh http:///.mp4 > /dev/null 2>&1
After that save file by hitting key combination Ctrl+X, confirm this action by entering y letter and hitting Enter key.
Now we can view our crontab file by crontab -l command.
If we need to disable this task, we need to comment task line by adding before it octothorpe symbol (#).
If we want to remove whole crontab file (double check that you know what you're doing!), we must use crontab -r command.
Short explanation. In the above example listed options mean:
-
MAILTO=""– sets empty E-mail address; -
*/10 08-18 * * *– task will start every 10 minutes from 08:00 to 18:50 every day; -
/home/ubdm/linux/process_video.sh– path to the script, which will be executed; -
http://<path to video file>/<file name>.mp4– first option (URL address to the video file); - second option (video encoder name) is absent, so FFmpeg will be used by default;
-
> /dev/null 2>&1– disables E-mail notifications about task status.
Windows part of the solution is responsible for downloading and/or creating of thumbnails list with further converting them to timelapse video file.
To run the script we need to pass several options for it.
Script accepts up to nine options (some of them are optional):
-
Start date with which we want to start including thumbnails (in format
YYYY-MM-DD, required):- YYYY – year, when thumbnails was created, 4 digits;
- MM – month (01 .. 12), when thumbnails was created, 2 digits;
- DD – day (01 .. 31), when thumbnails was created, 2 digits.
-
End date till which we want to include thumbnails (in format
YYYY-MM-DD, required); -
Source folder from which script will grab thumbnails (required). Can be of two types:
-
networking folder (starting with
\\); -
local folder (starting with drive letter, like
C:\).
-
networking folder (starting with
- Username for networking folders mounting (required even if source folder is local folder);
-
Copy flag that determinates files copying to the
tmpfolder (optional). Can accept two values:- 1 – files will be copied to the temporary folder;
- 0 – files will be read directly (set by default).
- Frames per second value of the timelapse video file (optional, 30 fps set by default);
- Duration in seconds of the timelapse video file (optional, 60 seconds set by default);
- Output video resolution (optional, 1920x1080 px set by default (native), half-size (960x540 px) or custom resolution is also acceptable);
- Output video quality (optional, 23 is fine and set by default; numbers from 0 to 51 is also acceptable: larger number mean poorer quality).
Please note, that script can't launch properly, if one of required options are omitted.
Also, for correct script launching please avoid omitting of previously going options before option, that you want to set (even if them are optional).
So full launch string can be look like this (reading thumbnails for period from 1 of March, 2017 to 8 of March, 2017 from network folder \\Server\files\archive with copying them to temporary folder, username is User, FPS is set to 24, video length is 120 seconds (2 minutes), video resolution is set to 960x540 pixels, video quality is 18):
C:\ubdm\windows\process_thumbs.bat 2017-03-01 2017-03-08 \\Server\files\archive User 1 24 120 960x540 18.
Short version of this string can be like (reading thumbnails for period from 1 of January, 2017 to 28 of February, 2017 from local folder D:\archive directly, default values for optional options are used and required option Username is additionally set to User):
C:\ubdm\windows\process_thumbs.bat 2017-01-01 2017-02-28 D:\archive User.
Script will create several folders near itself:
-
tmp– folder for temporary files, which will be deleted after processing (here is stored grabbed thumbnails with naming patternNNNNNN.jpg(where NNNNNN are numbers from 000000 to 999999) and filelistsrc_files.listwith thumbnail file names for the processing; -
video– folder containing converted timelapse video files named likeYYYY-MM-DD_YYYY-MM-DD_XXXXXXXX.mp4, where:-
YYYY-MM-DD –
Start dateandEnd daterespectively, 8 digits; - XXXXXXXX – unique CRC32 hash of the video file, 8 alphanumeric symbols.
-
YYYY-MM-DD –