Video processing and publishing
Scripts
encode_all.sh
#!/bin/bash # Copyright (c) 2011 Rikard Fröberg <rikard@ffkp.se>. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA NAS_MOUNT="YOUR_NAS_MOUNT_POINT_HERE" START_TIME=$(date) STARTSECS=$(date +%s) ENCODE_DIR="encoding" OUTPUT_DIR="$ENCODE_DIR/encoded_vids" PREPEND_DIR="$ENCODE_DIR/prepends" CREDITS="$PREPEND_DIR/1920-title.avi" LICENSE="$PREPEND_DIR/cc-1920.avi" MENCODER_OPTS="-oac copy -ovc copy -o" if [ ! -e "$ENCODE_DIR" ] ; then echo "$ENCODE_DIR not found. Exiting." exit 1 fi echo Starting at $START_TIME echo Dir to process: $ENCODE_DIR # Directories starting with a number contains MTS video files in our case for SESSION_DIR in $ENCODE_DIR/[0-9]* do countMTS=0 echo ============================ echo $(date) Processing $SESSION_DIR echo # Our raw files all end with .MTS for SESSION_MOVIE in ${SESSION_DIR}/*.MTS do ((++countMTS)) SESSION_SHORT=${SESSION_MOVIE##encoding/} AVI="${SESSION_SHORT%%/*}-$countMTS.avi" FINAL_AVI="${SESSION_SHORT%%/*}-$countMTS-all.avi" echo $(date) Running: "bin/encode.sh $SESSION_MOVIE $OUTPUT_DIR/$AVI" # Our nas was mounted over the network, double check that the # mount has not been lost due to network problems if [ ! -e "$SESSION_MOVIE" ] then echo "$SESSION_MOVIE" NOT FOUND. if [ -d "$NAS_MOUNT" ] then echo "NAS mounted on $NAS_MOUNT" else echo "NAS NOT mounted!" fi exit 2 fi bin/encode.sh "$SESSION_MOVIE" "$OUTPUT_DIR/$AVI" echo $(date) Running: "mencoder $MENCODER_OPTS $OUTPUT_DIR/$FINAL_AVI $CREDITS $LICENSE $OUTPUT_DIR/$AVI" /usr/bin/mencoder $MENCODER_OPTS $OUTPUT_DIR/$FINAL_AVI $CREDITS $LICENSE $OUTPUT_DIR/$AVI echo $OUTPUT_DIR/$FINAL_AVI created at $(date) echo "++++++++++++++" done done ENDSECS=$(date +%s) TOTAL_SECS=$((ENDSECS-STARTSECS)) ENDTIME=$(date) echo "Report:" echo "Encoding started at $START_TIME" echo "Encoding ended at $ENDTIME" echo "Encoding took ${TOTAL_SECS}secs or" echo " $((TOTAL_SECS/60))mins and $((TOTAL_SECS%60))secs or" echo " $((TOTAL_SECS/3600))hrs and $((TOTAL_SECS/60%60))mins and $((TOTAL_SECS%60))secs"
encode.sh
- !/bin/bash
- Copyright (c) 2011 Rikard Fröberg <rikard@ffkp.se>.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Prerequisites
- In order to run the encoding scripts, a number of tools, libraries and
- codecs need to be installed.
- The video transformation tools are:
- * ffmpeg
- * mencoder
- The codecs are:
- * libavcodec-extra-52
- * libaften0 - Not required if you have the license and title AVIs!
- (for creating the title and license AVI, we needed it to have fake
- silent audio as AC3 to match the AVIs created from the Session MTS
- files, or mencoder would protest)
- To test the results:
- * mplayer
infile=$1
outfile=$2
inputopts="-i $infile"
audioopts="-acodec copy"
videoopts="-vcodec libx264 -s 1280x720 -vpre default -b 2000000 -r 25"
echo "ffmpeg command:"
echo $inputopts $audioopts $videoopts $outfile
/usr/bin/ffmpeg $inputopts $audioopts $videoopts $outfile