Last active
July 27, 2020 12:23
-
-
Save slashinfty/d5e449a8aaed4ea6f1c5488d1752ac98 to your computer and use it in GitHub Desktop.
Verifying runs
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
# must hanve youtube-dl streamlink ffmpeg bc | |
# these specific commands also have the IBMPlexMono-Regular.ttf text file in the /hdd/verification/ folder | |
## edit all commands as necessary | |
alias yt-dl='yt-frames' | |
# must pass youtube video slug | |
function yt-frames() { | |
cd /hdd/verification/ | |
rm -f temp_frames.mp4 | |
youtube-dl -o 'temp.mp4' -f 298/134 --hls-prefer-ffmpeg $1 | |
FRAMERATE=$(ffprobe -show_streams temp.mp4 2>&1 | grep fps | awk '{split($0,a,"fps")}END{print a[1]}' | awk '{print $NF}') | |
ffmpeg -i temp.mp4 -vf "drawtext=fontfile=IBMPlexMono-Regular.ttf: text=(${FRAMERATE}) %{n}: start_number=1: x=10: y=10: fontcolor=black: fontsize=16: box=1: boxcolor=white: boxborderw=5" -preset ultrafast -c:a copy temp_frames.mp4 | |
rm temp.mp4 | |
mpv temp_frames.mp4 & | |
} | |
alias t-dl='twitch-frames' | |
# must pass twitch video url | |
function twitch-frames() { | |
cd /hdd/verification/ | |
rm -f temp_frames.mp4 | |
streamlink $1 720p60,360p,best -o temp.mp4 | |
FRAMERATE=$(ffprobe -show_streams temp.mp4 2>&1 | grep fps | awk '{split($0,a,"fps")}END{print a[1]}' | awk '{print $NF}') | |
ffmpeg -i temp.mp4 -vf "drawtext=fontfile=IBMPlexMono-Regular.ttf: text=(${FRAMERATE}) %{n}: start_number=1: x=10: y=10: fontcolor=black: fontsize=16: box=1: boxcolor=white: boxborderw=5" -preset ultrafast -c:a copy temp_frames.mp4 | |
rm temp.mp4 | |
mpv temp_frames.mp4 & | |
} | |
alias fsec='frame-seconds' | |
# must pass start frame, end frame, frame rate | |
function frame-seconds() { | |
TOTALSEC=$(echo "scale=3; ($2-$1)/$3" | bc) | |
MS=${TOTALSEC:(-3)} | |
SECONLY=${TOTALSEC:0:-4} | |
if [[ SECONLY -gt 59 ]] | |
then | |
SEC=$(echo "$SECONLY%60" | bc) | |
MINONLY=$(echo "$SECONLY/60" | bc) | |
if [[ MINONLY -gt 59 ]] | |
then | |
MIN=$(echo "$MINONLY%60" | bc) | |
HR=$(echo "$MINONLY/60" | bc) | |
printf "%s hr %s min %s sec %s ms" $HR $MIN $SEC $MS | |
else | |
printf "%s min %s sec %s ms" $MINONLY $SEC $MS | |
fi | |
else | |
printf "%s sec %s ms" $SECONLY $MS | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Windows:
Download:
youtube-dl
streamlink
ffmpeg
Put youtube-dl.exe and ffmpeg.exe in home folder.
Open PowerShell.
If YouTube:
If Twitch:
(change 720p60 to 360p if no 720p60 source)
((change 360p to best if no 360p source))
Apply frame count: