public:ffmpeg-based_interval_timer_for_sport_and_exercise
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
public:ffmpeg-based_interval_timer_for_sport_and_exercise [2018/02/07 02:44] – [Example output] fangfufu | public:ffmpeg-based_interval_timer_for_sport_and_exercise [2018/02/09 18:06] – fangfufu | ||
---|---|---|---|
Line 12: | Line 12: | ||
<code bash> | <code bash> | ||
#!/bin/bash | #!/bin/bash | ||
+ | |||
+ | # The content of the set | ||
+ | # Format: | ||
+ | # min:sec text | ||
+ | turbo=( | ||
+ | #Warm up | ||
+ | '05:00 90 RPM Smooth pedalling' | ||
+ | '02:00 95 RPM Smooth pedalling' | ||
+ | '02:00 100 RPM Smooth pedalling' | ||
+ | '02:00 105 RPM Smooth pedalling' | ||
+ | '01:30 110 RPM Smooth pedalling' | ||
+ | '00:30 120-130 RPM Maintain form' | ||
+ | '02:00 90 RPM Relax and recover' | ||
+ | '00:06 MAX RPM Rev out' | ||
+ | '01:00 90 RPM Smooth pedalling' | ||
+ | '00:06 MAX RPM Rev out' | ||
+ | '01:00 90 RPM Smooth pedalling' | ||
+ | '00:06 MAX RPM Rev out' | ||
+ | '02:45 90 RPM Relax and recover' | ||
+ | #Russian Steps | ||
+ | '00:15 Max effort' | ||
+ | '00:45 Recovery' | ||
+ | '00:30 Max effort' | ||
+ | '00:30 Recovery' | ||
+ | '00:45 Max effort' | ||
+ | '00:15 Recovery' | ||
+ | '01:00 Max effort' | ||
+ | '01:00 Recovery' | ||
+ | '00:45 Max effort' | ||
+ | '00:15 Recovery' | ||
+ | '00:30 Max effort' | ||
+ | '00:30 Recovery' | ||
+ | '00:15 Max effort' | ||
+ | '05:45 Recovery' | ||
+ | '00:15 Max effort' | ||
+ | '00:45 Recovery' | ||
+ | '00:30 Max effort' | ||
+ | '00:30 Recovery' | ||
+ | '00:45 Max effort' | ||
+ | '00:15 Recovery' | ||
+ | '01:00 Max effort' | ||
+ | '01:00 Recovery' | ||
+ | '00:45 Max effort' | ||
+ | '00:15 Recovery' | ||
+ | '00:30 Max effort' | ||
+ | '00:30 Recovery' | ||
+ | '00:15 Max effort' | ||
+ | '05:45 Recovery' | ||
+ | '00:15 Max effort' | ||
+ | '00:45 Recovery' | ||
+ | '00:30 Max effort' | ||
+ | '00:30 Recovery' | ||
+ | '00:45 Max effort' | ||
+ | '00:15 Recovery' | ||
+ | '01:00 Max effort' | ||
+ | '01:00 Recovery' | ||
+ | '00:45 Max effort' | ||
+ | '00:15 Recovery' | ||
+ | '00:30 Max effort' | ||
+ | '00:30 Recovery' | ||
+ | '00:15 Max effort' | ||
+ | '10:00 Cool Down' | ||
+ | ) | ||
+ | ################################################################################ | ||
+ | resolution=1280x720 | ||
+ | framerate=30 | ||
# The file number counter | # The file number counter | ||
let counter=0 | let counter=0 | ||
+ | |||
+ | # The length of the set | ||
+ | let setLen=${# | ||
function cleanup { | function cleanup { | ||
- | rm seg-*.mp4 filelist.txt | + | rm seg-*.mp4 filelist.txt intro.txt |
} | } | ||
- | # Calling convention: duration, | + | # Calling convention: duration, |
function introduction { | function introduction { | ||
- | ffmpeg -f lavfi -i color=c=white: | + | ffmpeg -f lavfi -i color=c=white: |
- | -vf " | + | -vf " |
- | r=30: x=(w-tw)/2: y=h-h*0.9: fontcolor=black:" | + | r=${framerate}: x=(w-tw)/2: y=h-h*0.9: fontcolor=black:" |
- | -t ${1} -preset | + | -t ${1} -preset |
seg-${counter}.mp4 | seg-${counter}.mp4 | ||
echo "file seg-${counter}.mp4" | echo "file seg-${counter}.mp4" | ||
Line 31: | Line 100: | ||
} | } | ||
- | # Calling convention: | + | # Calling convention: |
- | function | + | function |
- | let min=$1/60 | + | let duration=${1}*60+${2} |
- | | + | |
- | ffmpeg -f lavfi -i color=c=white: | + | sec=${2} |
- | -vf " | + | textNow=${3} |
- | r=30: x=(w-tw)/2: y=h-h*0.75: fontcolor=black:,\ | + | textNext=$(echo " |
+ | ffmpeg -f lavfi -i color=c=white: | ||
+ | -vf "\ | ||
+ | | ||
+ | r=${framerate}: x=(w-tw)*0.5: y=h-h*0.80: fontcolor=Black:,\ | ||
+ | | ||
drawtext=text=' | drawtext=text=' | ||
- | r=30: x=(w-tw)/2: y=h-h*0.5: fontcolor=black:, | + | r=${framerate}: x=(w-tw)*0.5: y=h-h*0.60: fontcolor=Black:, |
+ | \ | ||
drawtext=timecode=' | drawtext=timecode=' | ||
- | r=30: x=(w-tw)/2: y=h-h*0.25: fontcolor=black:" \ | + | r=${framerate}: x=(w-tw)*0.5: y=h-h*0.40: fontcolor=Black:, \ |
- | -t ${1} -preset | + | \ |
+ | drawtext=text=' | ||
+ | r=${framerate}: | ||
+ | | ||
+ | -t ${duration} -preset | ||
seg-${counter}.mp4 | seg-${counter}.mp4 | ||
echo "file seg-${counter}.mp4" | echo "file seg-${counter}.mp4" | ||
Line 53: | Line 132: | ||
} | } | ||
+ | # Calling convention: segment_id | ||
+ | function turboSegment { | ||
+ | thisLine=$(echo ${turbo[${1}]}) | ||
+ | timing=$(echo $thisLine|cut -d ' ' -f 1) | ||
+ | min=$(echo $timing|cut -d ':' | ||
+ | sec=$(echo $timing|cut -d ':' | ||
+ | textNow=$(echo $thisLine|cut -d ' ' -f 2-) | ||
+ | |||
+ | let segNext=${1}+1 | ||
+ | textNext=$(echo ${turbo[${segNext}]}|cut -d ' ' -f 2-) | ||
+ | videoSegment $min $sec " | ||
+ | } | ||
+ | ################################################################################ | ||
cleanup | cleanup | ||
- | ############################################################################ | ||
- | # -- Insert your session introduction here -- # | ||
- | # Make sure the font is big enough! You might want to test out the # | ||
- | # introduction generation first by commenting out the main set # | ||
- | # Calling convention: | ||
- | # introduction $DURATION $FONTSIZE $TEXT # | ||
- | ############################################################################ | ||
- | introduction 10 40 " | ||
- | Threshold session: | ||
- | W/U - 5 minutes easy, gradually build up | + | # Create the introduction text variable |
- | 10 mins at 10 mile TT effort | + | printf " |
- | 15 seconds sprint | + | |
- | 10 mins easy | + | # introduction |
- | 10 mins at 10 mile TT effort | + | |
- | 20 seconds sprint | + | |
- | 10 mins easy | + | |
- | 10 mins 10 mile TT effort | + | |
- | 25 seconds sprint | + | |
- | Warm down for 5 mins, easy spinning | + | |
- | " | + | |
- | ############################################################################ | + | # read -p "Press any key to continue, or Ctrl+C to stop..." |
- | # -- Insert your main set here. -- # | + | |
- | # You might want to test out the introduction generation before generating # | + | |
- | # these video. # | + | |
- | # Calling convention: | + | |
- | # segment $DURATION $TEXT # | + | |
- | ############################################################################ | + | |
- | segment 300 "Easy, gradually build up" | + | for i in $(seq 0 $setLen); do |
- | segment 600 "10 mile TT effort" | + | |
- | segment 15 " | + | done |
- | segment 600 " | + | |
- | segment 600 "10 mile TT effort" | + | |
- | segment 20 " | + | |
- | segment 600 " | + | |
- | segment 600 "10 mile TT effort" | + | |
- | segment 25 " | + | |
- | segment 300 "Cool down" | + | |
- | output UEA-Triathlon-2018-02-07.mp4 | + | output UEA-Triathlon-$(date |
</ | </ | ||
public/ffmpeg-based_interval_timer_for_sport_and_exercise.txt · Last modified: 2018/03/31 00:38 by 127.0.0.1