Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 92 lines (76 sloc) 2.82 KB
#!/bin/bash
sub_seconds_from_timestamp() {
python3 -c "from datetime import timedelta;f=lambda t: timedelta(hours=int(t[:2]), minutes=int(t[3:5]), seconds=int(t[6:8]), microseconds=int(''.join([t[9+i:10+i] or '0' for i in range(6)])));print(f('$1')-timedelta(seconds=$2))"
}
# a=00:03:04.200
# b=00:05:30
# c=$(diff_timestamps $a $b)
. settings.env
regex="^[0-9]{2}:[0-9]{2}:[0-9]{2}\.?[0-9]*$"
for video_dir in $WORKING_DIR/*/ ;
do
# We need to find the start and the end of the talk. Start mpv with
# some osd settings set, so the user will be able to search for start
# and end.
# TODO: Save --start option into variable to avoid duplicate mpv vall
if [ -f ${video_dir}screen_offset.txt ]; then
mpv --osd-fractions \
--osd-level 2 \
--osd-playing-msg="Search for the start of the talk" \
--osd-duration=3600000 \
--start=$(cat ${video_dir}screen_offset.txt) \
${video_dir}cam.mp4
else
mpv --osd-fractions \
--osd-level 2 \
--osd-playing-msg="Search for the start of the talk" \
--osd-duration=3600000 \
${video_dir}cam.mp4
fi
unset confirmation
while [[ ! $confirmation =~ [yY] ]]; do
unset timestamp
while [[ ! $timestamp =~ $regex ]]; do
read -p 'When does the talk start? (hh:mm:ss.s): ' timestamp
done
replay='y'
while [[ $replay =~ [yY] ]]; do
mpv --osd-fractions \
--osd-level 2 \
--start=$timestamp \
--length=3 \
--osd-playing-msg="Started at $timestamp" \
--osd-duration=10000 \
${video_dir}cam.mp4
read -p "Replay? [y/N] " replay
done;
read -p 'Does it look good? [y/N] ' confirmation
done;
echo $timestamp > ${video_dir}talk_start.txt
mpv --osd-fractions \
--osd-level 2 \
--start=-30 \
--osd-playing-msg="Search for the end of the talk" \
--osd-duration=3600000 \
${video_dir}cam.mp4
unset confirmation
while [[ ! $confirmation =~ [yY] ]]; do
unset timestamp
while [[ ! $timestamp =~ $regex ]]; do
read -p 'When does the talk end? (hh:mm:ss.s): ' timestamp
done
replay='y'
while [[ $replay =~ [yY] ]]; do
mpv --osd-fractions \
--osd-level 2 \
--start=$(sub_seconds_from_timestamp $timestamp 5) \
--end=$timestamp \
--osd-playing-msg="Will end at $timestamp" \
--osd-duration=10000 \
${video_dir}cam.mp4
read -p "Replay? [y/N] " replay
done;
read -p 'Does it look good? [y/N] ' confirmation
done;
echo $timestamp > ${video_dir}talk_end.txt
done