anchor.diff:  for %%f in (%FRAMESTEMPDIR%/*.jpg) do (
   :: For whatever reason (this has to be at the beginning of the line!)
     echo Processing frame %FRAMESTEMPDIR%\%%f
  -:: There should be some error checking
  +:: TODO: There should be some error checking
     call gear360pano.cmd %FRAMESTEMPDIR%\%%f %OUTTEMPDIR%\%%f
   )
   
  -"%FFMPEGPATH%/ffmpeg.exe" -f image2 -i %OUTTEMPDIR%/%IMAGETMPL% -r 30 -s 3840:1920 -vcodec libx264 %OUTNAME%
  +echo "Reencoding video..."
  +"%FFMPEGPATH%/ffmpeg.exe" -y -f image2 -i %OUTTEMPDIR%/%IMAGETMPL% -r 30 -s 3840:1920 -vcodec libx264 %OUTTEMPDIR%/%TMPVIDEO%
  +if %ERRORLEVEL% EQU 1 GOTO FFMPEGERROR
  +
  +echo "Extracting audio..."
  +"%FFMPEGPATH%/ffmpeg.exe" -y -i %1 -vn -acodec copy %OUTTEMPDIR%/%TMPAUDIO%
  +if %ERRORLEVEL% EQU 1 GOTO FFMPEGERROR
  +
  +echo "Merging audio..."
  +
  +:: Check if second argument present, if not, set some default for output filename
  +:: This is here, because for whatever reason OUTNAME gets overriden by
  +:: the last iterated filename if this is at the beginning (for loop is buggy?)
  +if not [%2] == [] goto SETNAMEOK
  +set OUTNAME="%~n1_pano.mp4"
  +
  +:SETNAMEOK
  +
  +"%FFMPEGPATH%/ffmpeg.exe" -y -i %OUTTEMPDIR%/%TMPVIDEO% -i %OUTTEMPDIR%/%TMPAUDIO% -c:v copy -c:a aac -strict experimental %OUTNAME%
   if %ERRORLEVEL% EQU 1 GOTO FFMPEGERROR
   
   :: Clean-up (f - force, read-only & dirs, q - quiet)
  
positive.code: ################################ Linux part here
  
  # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-which-directory-it-is-stored-in
  # Or dirname `dirname $0`
  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  
  # Clean-up function
  function clean_up {
      echo "Removing temporary directories..."
      if [ -d "FRAMESTMPDIR" ]; then
          rm -rf "FRAMESTMPDIR"
      fi
      if [ -d "OUTTEMPDIR" ]; then
          rm -rf "OUTTEMPDIR"
      fi
  }
  
  # Function to check if a command fails
  # http://stackoverflow.com/questions/5195607/checking-bash-exit-status-of-several-commands-efficiently
  function run_command {
      "$@"
      local status=$?
      if [ $status -ne 0 ]; then
          echo "Error while running $1" >&2
          clean_up
          exit 1
      fi
      return $status
  }
  
  # Do stuff to make this thing run on various operating systems
  # http://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
  function os_check {
      case "$(uname -s)" in
  
      Darwin)
  
negative.code: echo ffmpeg failed, video not created
  goto END
  
  :END
  