So, M. works on this piece with students of Duncan Centre and SVŠGL, currently in Prague. Later rehearsals will happen in Ljubljana. Anyway, she’s documenting rehearsals on HD camera, which produces HD h264-encoded clips, that are practically unwatchable on her X200 thinkpad. So I wrote a little script that downloads the clips to an external drive and converts them to WEBM format. I think it’s one of the neatest scripts so far from me, as it even uses little error checking (for existence of folders for example).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
#!/bin/bash # a script to download clips from camera # branch: Prague # version: 140221 DEST="/media/My Passport/praga/" SOURCE="/media/CAM_MEM/AVCHD/BDMV/STREAM/" if [ ! -d "$DEST" ]; then echo "ERROR: destination folder '$DEST' does not exist!" echo "Is your external USB drive plugged in?" echo "Aborting, sorry." exit fi if [ ! -d "$SOURCE" ]; then echo "WARNING: source folder '$SOURCE' does not exist!" echo "This means that camera is not connected (yet / any more)." echo "We will proceed to look into destination folder if there" echo "is anything left to encode." echo read -p "Press any key to continue... " -n1 -s echo echo fi if [ -d "$SOURCE" ]; then # go to source dir cd "$SOURCE" pwd ls echo ======================================================= echo "copying ..." for i in *.MTS do cp -v $i "$DEST"`stat -c %y $i | sed 's/.\([0-9]\{9\}\) +\([0-9]\{4\}\)//g' | sed 's/:/_/g' | sed 's/ /__/'`.mts; done; echo; echo "done ..." fi echo ======================================================= cd "$DEST" echo "now working in " `pwd` "..." echo "will now convert *.mts to webm format..." for i in *.mts do echo ======================================================= echo "converting $i ..." avconv -i "$i" -y -s 854x480 -threads 2 -c:v libvpx -f webm -b:v 1M -g 120 -qmax 63 -qmin 0 -maxrate 1.5M -minrate 40k -c:a libvorbis -ab 128k -async 44100 `echo $i|sed 's/.mts/.webm/'` echo ======================================================= echo "moving $i away to mts subfolder..." mv -v $i mts/ mv -v `echo $i|sed 's/.mts/.webm/'` webm/ echo ======================================================= echo; echo; echo; echo; done echo; echo "done ..." echo echo ======================================================= echo end of script. have a nice day!! :\) echo ======================================================= echo check webm folder in $DEST echo if everything is encoded well. echo if happy, don\'t forget to erase clips from camera! echo ======================================================= echo read -p "Press any key to exit. " -n1 -s echo |