From d5eca944bda01ac92e18138eee4989215e9c956c Mon Sep 17 00:00:00 2001 From: Frederik Petersen Date: Wed, 22 May 2013 13:03:23 +0200 Subject: [PATCH] Added scripts for converting and downscaling videos The videos are downloaded from provided ftp server, converted and reuploaded into an out directory. They can then be referenced in the Video/Audio tab of the AdminConsole --- .../convertAndDownscaleVideos.sh | 54 +++++++++++++++++++ .../convertAndDownscaleVideosMulticore.sh | 45 ++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 configuration/video-conversion/convertAndDownscaleVideos.sh create mode 100644 configuration/video-conversion/convertAndDownscaleVideosMulticore.sh diff --git a/configuration/video-conversion/convertAndDownscaleVideos.sh b/configuration/video-conversion/convertAndDownscaleVideos.sh new file mode 100644 index 00000000000..7ef25027ee8 --- /dev/null +++ b/configuration/video-conversion/convertAndDownscaleVideos.sh @@ -0,0 +1,54 @@ +#!/bin/bash +#Fetches videos from the given ftp directory, downscales them +# and uploads them back into the directory+/out +# +# Notes on ffmpeg: Make sure to install an ffmpeg version with x264 support. +# You can either compile it yourself (there are various online tutorials) or +# just download it from the http://www.deb-multimedia.org/ repository (if you use debian) +HOST='sapevent.upload.akamai.com' +USER='sail' +PASS='S4iL!uPlo4D*' +LOCALDIR='/tmp/sailvids' +SOURCEDIR='/67696/sail/barbados' + +#Create temporary folder for videos +#rm -rf $LOCALDIR +mkdir $LOCALDIR + +#Download directory content (could be extended to filter for video files) +lftp -f " + open $HOST + user $USER $PASS + mirror --verbose -r $SOURCEDIR $LOCALDIR + bye +" + +#CREATE out dir +mkdir $LOCALDIR/out + +#ITERATE FOR VIDEOS +VIDEOFILES=$LOCALDIR/*.MP4 +COUNT=$(find $LOCALDIR -name "*.MP4" -print | wc -l) +STEP=0 +for f in $VIDEOFILES +do + FILENAME=$(basename "$f") + STEP=$(($STEP + 1)) + echo "Processing Video $STEP/$COUNT: $FILENAME" + #Just to make sure that this is no directory + test -f "$f" || continue + #Actual conversion + ffmpeg -y -i "$f" -vcodec libx264 -profile baseline -preset slow -b 1500k -s 1024*576 -r 25 "$LOCALDIR/out/$FILENAME" +done + + +#Mirror directory to remote (since only out/ is changed, +# only its contents will be uploaded) +lftp -f " + open $HOST + user $USER $PASS + mirror -r --reverse --verbose $LOCALDIR/out $SOURCEDIR/out + bye +" + +rm -rf $LOCALDIR \ No newline at end of file diff --git a/configuration/video-conversion/convertAndDownscaleVideosMulticore.sh b/configuration/video-conversion/convertAndDownscaleVideosMulticore.sh new file mode 100644 index 00000000000..bbf07b09796 --- /dev/null +++ b/configuration/video-conversion/convertAndDownscaleVideosMulticore.sh @@ -0,0 +1,45 @@ +#!/bin/bash +#Fetches videos from the given ftp directory, downscales them +# and uploads them back into the directory+/out +# Uses GNU parallel for multi-cpu usage +# +# Notes on ffmpeg: Make sure to install an ffmpeg version with x264 support. +# You can either compile it yourself (there are various online tutorials) or +# just download it from the http://www.deb-multimedia.org/ repository (if you use debian) +# +# Notes on GNU parallel: Make sure to install the GNU version of parallel (there are other +# programs with the same command. In debian: sudo apt-get install parallel +HOST='sapevent.upload.akamai.com' +USER='sail' +PASS='S4iL!uPlo4D*' +LOCALDIR='/tmp/sailvids' +SOURCEDIR='/67696/sail/barbados' + +#Create temporary folder for videos +#rm -rf $LOCALDIR +mkdir $LOCALDIR + +#Download directory content (could be extended to filter for video files) +time lftp -f " + open $HOST + user $USER $PASS + mirror --verbose -r $SOURCEDIR $LOCALDIR + bye +" + +#CREATE out dir +mkdir $LOCALDIR/out +#Reference all video files +echo "Starting to process videos" +#Starts gnu parallel with the conversion jobs +time ls $LOCALDIR/*.{MP4,mp4,AVI,avi,3GP,3gp,MPEG,mpeg,MPG,mpg} | parallel -u --gnu 'echo "Starting conversion for: {/}";ffmpeg -y -i {} -vcodec libx264 -profile baseline -preset slow -b 1500k -s 1024*576 -r 25 {//}/out/{/.}.MP4;echo "Finished conversion for: {/}"' + +#Mirror directory to remote +time lftp -f " + open $HOST + user $USER $PASS + mirror -r --reverse --verbose $LOCALDIR/out $SOURCEDIR/out + bye +" + +rm -rf $LOCALDIR \ No newline at end of file