I am working on a bash script for encoding videos with ffmpeg in a special format. To save the resulting videos I want to upload the video as soon as the encoding is finished. Therefore I want to use parallel processing in my script.
A short example:
#!/bin/bash
uploading() {
upload $1
}
encoding() {
ffmpeg video video_encoded
uploading $video_encoded
}
If my encoding is faster then the uploading function it would create a new background process. This is not what I want. The wanted behavior is that if the uploading process is still alive my encoding function should save the required parameters (e.g. video path) in some kind of queue so that the upload function check on its end whether the queue is empty or not and push and pop as required.
Is something like this possible in bash?
Thanks in advanced!