Close

OK that's a start at least

A project log for ISS HDEV image availability

The "High Definition Earth Viewing" experiment onboard the ISS runs a few cameras, but not always. Let's find out when video is available!

christophChristoph 09/20/2016 at 20:110 Comments

So I managed to write a bash script that

Here it is:

#!/bin/bash

threshold="0.1"

# http://stackoverflow.com/questions/18279540/bash-shutdown-hook-or-kill-all-background-processes-when-main-process-is-kille
trap 'jobs -p | xargs --no-run-if-empty kill' EXIT

livestreamer --player "ffmpeg -i" --player-args "{filename} -vf fps=0.1 out%04d.png" https://www.ustream.tv/channel/17074538 worst &

while true; do
    # find newest file and compare
    FILE=$(ls -t out*.png | head -n 1)
    { output=$(compare -metric MSE -fuzz 20% $FILE references/novideo.png tmp.jpg 2>&1 1>&3-) ;} 3>&1
    # extract and compare, output binary value indicating if HDEV stream is available or not
    value=$(echo $output | cut -d "(" -f2 | cut -d ")" -f1)
    echo $value'>'$threshold | bc -l 

    # remove old files
    # http://stackoverflow.com/questions/25785/delete-all-but-the-most-recent-x-files-in-bash
    (ls -t out*.png | head -n 2;ls out*.png)|sort|uniq -u | xargs --no-run-if-empty rm

    # check if livestreamer is still running and restart if required
    # TBD ...

    sleep 5

done
Some things are still missing:

Discussions