I have a simple script that loops through files in a folder and then converts them from flv to mp4. How in bash do I skip over the files in the folder that have a fcntl lock on them and then come back when the lock is removed?
#!/bin/bash
for file in /video_recordings/stream/*.flv; do
today=`date '+%Y_%m_%d_%H_%M_%S'`;
cp -v "$file" /video_recordings/stream/backups/$today.flv;
[ -e "${file%.flv}".mp4 ] || ffmpeg -threads 1 -i "$file" -c:v libx264 -c:a aac -b:v 768k -b:a 96k -vf "scale=720:trunc(ow/a/2)*2" -tune fastdecode -preset ultrafast -crf 25 /video_recordings/stream/temp/$today.mp4
cp -v /video_recordings/stream/temp/$today.mp4 /video_recordings/stream/vod/$today.mp4
rm /video_recordings/stream/temp/$today.mp4
sleep 15s;
rm "$file";
done