Iím trying to automatically transcode videos with are begin uploaded constantly to a server.
That's why I have came up with the idea of using inotify by checking every moment for new files on the videos folder, by using this shell script:
When a new file is moved or created over /usr/local/share/downloads, it called to another script over ~/convertvideos/convert.sh.Code:#!/bin/bash inotifywait --monitor -e moved_to -e create /usr/local/share/downloads | while read dir; do (~/convertvideos/convert.sh) done
The idea of the convert.sh file is to convert every video which is within the /usr/local/share/download directory, and within every single folder.
The contents of convert.sh is:
ON my server for the first files within the /downloads/ folder works, but after it finishes transcoding it starts again transcoding the same files, and for example if there is one folder down, let say /downloads/Anthony Zimmer FRENCH/ it should search for any video file and transcode it. After that it should delete the non transcoded file. and perhaps move the transcoded file to another folder.Code:#!/bin/bash for file in /usr/local/share/downloads/* do ffmpeg -i "$file" -acodec aac -ac 2 -ar 44100 -ab 128k -strict -2 -vcodec libx264 "$file".mp4 < /dev/null rm "$file" done
How can I get this to work?
+ Reply to Thread
Results 1 to 2 of 2
In the convert.sh script move all the files to a new location(like /usr/local/share/convert) and the convert them. Or else will the new files be converted for ever.