fish: functions/tsd: Add a helper to analyse GStreamer timestamps

This commit is contained in:
Sanchayan Maity 2022-04-16 13:57:05 +05:30
parent 800ec4ca64
commit 0afe1044c1

View file

@ -0,0 +1,23 @@
# This function is to help us analyse timestamp difference given a file with
# a single column where each row has GStreamer PTS/DTS/Duration or timestamp
# of the form HH:MM:SS:sssssssss in each row.
# Adapted from https://stackoverflow.com/questions/8903239/how-to-calculate-time-elapsed-in-bash-script
function tsd --description "Get timestamp difference between rows" -a file
if test (count $argv) -lt 1
echo "Usage: tsd <file_name>"
echo "Eg: tsd gstreamer-ts.log"
else
set -l RESULT_FILE /tmp/gst-ts-analysis.csv
if test -e $RESULT_FILE
echo "Result file $RESULT_FILE exists, removing..."
rm $RESULT_FILE
end
while read -la first_line; and read -la second_line
set -l fist_date $(date -u -d "$first_line" +"%s.%N")
set -l second_date $(date -u -d "$second_line" +"%s.%N")
date -u -d "0 $second_date sec - $fist_date sec" +"%H:%M:%S.%N" >>$RESULT_FILE
end <$file
nvim -R $RESULT_FILE
end
end