Friday, February 26, 2016

Decoding Black Knight Satellite -- Recon

#!/usr/bin/env bash 

#############################################################################
###########################################################################
### Created by A.M.Danischewski (c) 2016 v1.00
### Issues: If you find any issues emai1 me at my <first name> dot 
###         <my last name> at gmail dot com.  
###
### This program is intended to facilitate the recording of the Live ISS 
### feed at http://www.ustream.tv/channel/live-iss-stream
### 
### I noticed that the downloaded files offered on the Ustream servers 
### seldom matched what I was viewing on the realtime stream from the 
### website. 
###
###  See the following for more background on the Black Knight Satellite: 
###    https://www.youtube.com/watch?v=3RmSKT-9u_A 
###    https://www.youtube.com/watch?v=eO6a_e2u0c4
### 
### To use this software, configure the download location variable below
### and add the aliases to your ~/.bashrc file. Then periodically open a 
### webbrowser to: http://www.ustream.tv/channel/live-iss-stream
###
### If you see anything interesting, type $> rbk and make sure the webbrowser
### window remains visible (it records exactly what you see on your desktop
### screen). When the anomolous/interesting activity is over, go back to 
### the recording terminal window and hit Ctrl-C to stop the recording. 
### Afterward you can view the recent recording by typing in $> vbk. 
###
### Upload your findings to Youtube as soon as possible. 
###  
### This program requires (to work to full capacity) by default: 
### bash, avconv/ffmpeg, vlc 
### 
### Other useful software, youtube-dl for downloading youtube videos: 
###   https://rg3.github.io/youtube-dl/
### 
### 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 3 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.
###
###########################################################################
#############################################################################

########  ### CHANGE ###  ### OUTPUT DIR ###  CHANGE THIS #### 
## Change the following to the location of a large drive where you 
## want the desktop recordings to live. 
##
 declare OUTPUTDIR="/mnt/seagate1/ISS/" ### CHANGE THIS 
##
#################### END CHANGE 

 ## These should be sensible for most people. 
declare FILE_PREFIX="ISS_$(date +%Y%m%d)"
declare RESOLUTION="1280x720" 
declare FRAMERATE="25" 
declare AVCONVPROG="$(which ffmpeg || which avconv)" 
declare DISCARD_DEV=/dev/random  ## If not on Linux, change to /dev/null
declare VIDEOCODEC="libx264" 
 ## If you are on Crouton or other chroot, change this (E.g. ":1.0+0,0")
declare CAPTUREDISPLAY=":0.0+0,0" 
declare OUTPUTSUFFIX="mkv" 

function get_max_iss_seq() {
 MAXSEQ=$( { ls -p "${OUTPUTDIR%/}/${FILE_PREFIX}"* | tr '.' '_' | grep -E "${FILE_PREFIX}_[0-9]*" | sort -n -t _ -k 3 | tail -1 | cut -d_ -f3; } 2>"${DISCARD_DEV}")
 echo "$((${MAXSEQ}+1))"
} 

function print_aliases() {  
cat << EOF
alias go2iss='cd "${OUTPUTDIR}"'  
alias rbk='${0} -r' 
alias arbk='${0} -ar' 
alias vbk='go2iss; vlc "\$(ls -tr ISS* | tail -1)"' 
EOF
} 

(($#==0)) && echo "Usage: ${0##*/} [-r (record)] [-ar (record with audio)] [-p (print aliases)]" && exit 0 
[[ ! -z "${1}" && "${1}" =~ ^-p ]]  && print_aliases && exit 0 
[[ ! -z "${1}" && "${1}" =~ ^-r ]]  && "${AVCONVPROG}" -f x11grab -r ${FRAMERATE} -s ${RESOLUTION} -i "${CAPTUREDISPLAY}" -vcodec ${VIDEOCODEC} -pre lossless_ultrafast -threads 0  "${OUTPUTDIR%/}/${FILE_PREFIX}_$(get_max_iss_seq).${OUTPUTSUFFIX}" && exit 0 
[[ ! -z "${1}" && "${1}" =~ ^-ar ]] && "${AVCONVPROG}" -preset medium -f alsa -i pulse -f x11grab -r ${FRAMERATE} -s ${RESOLUTION} -i "${CAPTUREDISPLAY}" -vcodec ${VIDEOCODEC} -threads 0 -aq 10 -af "volume=volume=10dB:precision=fixed" -ar 44100 -crf 23 "${OUTPUTDIR%/}/${FILE_PREFIX}_$(get_max_iss_seq).${OUTPUTSUFFIX}" && exit 0 

No comments:

Post a Comment