User Tools

Site Tools


public:ffmpeg-based_interval_timer_for_sport_and_exercise

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
public:ffmpeg-based_interval_timer_for_sport_and_exercise [2018/02/07 02:07] fangfufupublic:ffmpeg-based_interval_timer_for_sport_and_exercise [2018/03/31 00:38] (current) – external edit 127.0.0.1
Line 6: Line 6:
 After digging through FFmpeg documentation [(https://trac.ffmpeg.org/wiki)] and the Internet, I figured out how to generate a text-based video.  After digging through FFmpeg documentation [(https://trac.ffmpeg.org/wiki)] and the Internet, I figured out how to generate a text-based video. 
  
-Here present the program listing, and an example output+have to say FFmpeg is one of my most abused softwareLast time I used FFmpeg to upload arbitrary file to Youtube [(https://github.com/fangfufu/Matlab-Data-Video-Converter)].  
  
-===== Program listing ===== +You can download it at [[https://github.com/fangfufu/make_interval_timer_video]].
-#!/bin/bash +
- +
-# The file number counter +
-let counter=0 +
- +
-function cleanup { +
-    rm seg-*.mp4 filelist.txt +
-+
- +
-# Calling conventionduration, font size, text +
-function introduction { +
-    ffmpeg -f lavfi -i color=c=white:size=1280x720:rate=30 \ +
-    -vf "drawtext=text='${3}': fontsize=${2}:+
-    r=30: x=(w-tw)/2: y=h-h*0.9: fontcolor=black:"+
-    -t ${1} -preset slow -tune stillimage -y \ +
-    seg-${counter}.mp4 +
-    echo "file seg-${counter}.mp4" >> filelist.txt +
-    let counter++ +
-+
- +
-# Calling convention: duration, text +
-function segment { +
-    let min=$1/60 +
-    let sec=$1-${min}*60 +
-    ffmpeg -f lavfi -i color=c=white:size=1280x720:rate=30 \ +
-    -vf "drawtext=text='${2}': fontsize=80:+
-    r=30: x=(w-tw)/2: y=h-h*0.75: fontcolor=black:,+
-    drawtext=text='Duration: ${min} min ${sec} sec': fontsize=80:+
-    r=30: x=(w-tw)/2: y=h-h*0.5: fontcolor=black:, +
-    drawtext=timecode='00\:00\:00\:00': fontsize=80:+
-    r=30: x=(w-tw)/2: y=h-h*0.25: fontcolor=black:"+
-    -t ${1} -preset slow -tune stillimage -y \ +
-    seg-${counter}.mp4 +
-    echo "file seg-${counter}.mp4" >> filelist.txt +
-    let counter++ +
-+
- +
-function output { +
-    ffmpeg -f concat -i filelist.txt -c copy -y ${1} +
-    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 +
-10 mins at 10 mile TT effort +
-15 seconds sprint +
-10 mins easy +
-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 +
-+
- +
-############################################################################ +
-# -- 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" +
-segment 600 "10 mile TT effort" +
-segment 15  "Sprint" +
-segment 600 "Easy" +
-segment 600 "10 mile TT effort" +
-segment 20  "Sprint" +
-segment 600 "Easy" +
-segment 600 "10 mile TT effort" +
-segment 25  "Sprint" +
-segment 300 "Cool down" +
- +
-output UEA-Triathlon-2018-02-07.mp4 +
-</code>+
  
 ===== Example output ===== ===== Example output =====
-[[https://www.youtube.com/watch?v=4dAoJzUBoJE|The turbo session set on 2018-02-08]]+[[https://www.youtube.com/watch?v=CYHr1SqeTHw|The turbo session set on 2018-02-08]]
  
  
public/ffmpeg-based_interval_timer_for_sport_and_exercise.1517969274.txt.gz · Last modified: 2018/03/31 00:38 (external edit)