Created
October 31, 2016 15:22
-
-
Save velnias75/a64cac31f18a793e9c89ea24c90e80f5 to your computer and use it in GitHub Desktop.
Simple time estimator for avconv, without any error checking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Simple time estimator for avconv, without any error checking | |
# | |
# Usage: timeleft.sh HH:MM:SS.nn SOURCE_FPS ENCODE_FPS TIME | |
# | |
# Notice: for fractional SOURCE_FPS multiply SOURCE_FPS to an integer | |
# and ENCODE_FPS by the same factor, | |
# i.e. ENCODE_FPS=24.92 and SOURCE_FPS=5 => 2492 500 | |
# | |
# Copyright (C) 2016 Heiko Schaefer <heiko@rangun.de> | |
# | |
# This work is free. You can redistribute it and/or modify it under the | |
# terms of the Do What The Fuck You Want To Public License, Version 2, | |
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details. | |
# | |
DUR=`date +'%s' -d "1970-01-01 $1Z"` | |
REM=$(((((DUR-$4)*$2)+($3/2))/$3)) | |
if [ $REM -ge 86400 ]; then | |
DAY=1 | |
else | |
DAY=0 | |
fi | |
NOW=`date +'%s'` | |
FIN=$((NOW+REM)) | |
PCT=$((((($4*100) + (DUR/2))/DUR))) | |
DTD=`date +"%F"` | |
DFN=`date -d @${FIN} +"%F"` | |
if [ $DAY -ne 0 ]; then | |
TL="~$(((REM+1800)/3600)) hours" | |
TF=`date -d @${FIN} +"%c"` | |
else | |
TL=`date -u -d @${REM} +"%T"` | |
if [ "$DTD" = "$DFN" ]; then | |
TF=`date -d @${FIN} +"%T"` | |
else | |
TF=`date -d @${FIN} +"%c"` | |
fi | |
fi | |
echo "$TL ($DUR) => $TF ($PCT %)" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment