-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
#################################### | ||
#Usage: | ||
#bin/encoder/encodeAll.sh: will encode all videos that are not already encoded. | ||
#bin/encoder/encodeAll.sh -f: will encode all videos that are although if already encoded. | ||
#################################### | ||
source 'bin/encoder/lib.sh' | ||
ENCODE_EXISTING=false | ||
|
||
function launchEncoding(){ | ||
CURRENTDIR=$1 | ||
for i in "${VIDEO_EXTENSION[@]}" | ||
do | ||
ls $CURRENTDIR/*.$i > /dev/null 2>&1 | ||
if [ $? -eq 0 ]; then | ||
bin/encoder/encoder.sh ${CURRENTDIR}/*.$i | ||
fi | ||
done | ||
} | ||
|
||
while getopts ":f" opt; do | ||
case $opt in | ||
f) | ||
echo "-f was triggered!" >&2 | ||
ENCODE_EXISTING=true | ||
;; | ||
\?) | ||
echo "Invalid option: -$OPTARG" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
for CURRENTDIR in $(ls -d ${MONITORDIR}/*) | ||
do | ||
echo ${CURRENTDIR} | ||
if [ -f ${CURRENTDIR}/index.m3u8 ]; then | ||
if [ "${ENCODE_EXISTING}" = true ]; then | ||
launchEncoding ${CURRENTDIR} | ||
else | ||
log "$LEVEL_INFO" "${CURRENTDIR} already encoded!" | ||
fi | ||
else | ||
launchEncoding ${CURRENTDIR} | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
#!/bin/bash | ||
#run this script to launch file watcher | ||
source 'bin/encoder/lib.sh' | ||
declare -a VIDEO_EXTENSION=("mp4" "flv" "mkv"); | ||
|
||
MONITORDIR="/vagrant/shared/e-media/web/e-media-data/video" | ||
inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE | ||
do | ||
in_array VIDEO_EXTENSION "${NEWFILE#*.}" | ||
if [ $? -eq 0 ]; then | ||
bin/encoder/encoder.sh $NEWFILE & | ||
if [ -f $NEWFILE ]; then | ||
in_array VIDEO_EXTENSION "${NEWFILE#*.}" | ||
if [ $? -eq 0 ]; then | ||
bin/encoder/encoder.sh $NEWFILE & | ||
fi | ||
fi | ||
done |