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 revisionNext revision | Previous revision | ||
public:ffmpeg-based_interval_timer_for_sport_and_exercise [2018/02/09 18:06] – fangfufu | public:ffmpeg-based_interval_timer_for_sport_and_exercise [2018/03/31 00:38] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 5: | Line 5: | ||
After digging through FFmpeg documentation [(https:// | After digging through FFmpeg documentation [(https:// | ||
- | |||
- | Here I present the program listing, and an example output. The script works fine on Debian Stretch. | ||
I have to say FFmpeg is one of my most abused software. Last time I used FFmpeg to upload arbitrary file to Youtube [(https:// | I have to say FFmpeg is one of my most abused software. Last time I used FFmpeg to upload arbitrary file to Youtube [(https:// | ||
- | ===== Program listing ===== | ||
- | <code 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 | ||
- | let counter=0 | ||
- | |||
- | # The length of the set | ||
- | let setLen=${# | ||
- | |||
- | function cleanup { | ||
- | rm seg-*.mp4 filelist.txt intro.txt | ||
- | } | ||
- | |||
- | # Calling convention: duration, font_size | ||
- | function introduction { | ||
- | ffmpeg -f lavfi -i color=c=white: | ||
- | -vf " | ||
- | r=${framerate}: | ||
- | -t ${1} -preset ultrafast -tune stillimage -y -loglevel panic -stats \ | ||
- | seg-${counter}.mp4 | ||
- | echo "file seg-${counter}.mp4" | ||
- | let counter++ | ||
- | } | ||
- | |||
- | # Calling convention: min, sec, text_now, text_next | ||
- | function videoSegment { | ||
- | let duration=${1}*60+${2} | ||
- | min=${1} | ||
- | sec=${2} | ||
- | textNow=${3} | ||
- | textNext=$(echo "Next -" ${min}m ${sec}s ${4}) | ||
- | ffmpeg -f lavfi -i color=c=white: | ||
- | -vf "\ | ||
- | drawtext=text=' | ||
- | r=${framerate}: | ||
- | \ | ||
- | drawtext=text=' | ||
- | r=${framerate}: | ||
- | \ | ||
- | drawtext=timecode=' | ||
- | r=${framerate}: | ||
- | \ | ||
- | drawtext=text=' | ||
- | r=${framerate}: | ||
- | \ | ||
- | -t ${duration} -preset ultrafast -tune stillimage -y -loglevel panic -stats \ | ||
- | seg-${counter}.mp4 | ||
- | echo "file seg-${counter}.mp4" | ||
- | let counter++ | ||
- | } | ||
- | |||
- | function output { | ||
- | ffmpeg -f concat -i filelist.txt -c copy -y ${1} | ||
- | cleanup | ||
- | } | ||
- | |||
- | # 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 | ||
- | |||
- | # Create the introduction text variable | ||
- | printf " | ||
- | |||
- | # introduction 10 40 | ||
- | |||
- | # read -p "Press any key to continue, or Ctrl+C to stop..." | ||
- | |||
- | for i in $(seq 0 $setLen); do | ||
- | turboSegment ${i} | ||
- | done | ||
- | output UEA-Triathlon-$(date --rfc-3339=date).mp4 | + | You can download it at [[https:// |
- | </code> | + | |
===== Example output ===== | ===== Example output ===== |
public/ffmpeg-based_interval_timer_for_sport_and_exercise.txt · Last modified: 2018/03/31 00:38 by 127.0.0.1