Bash Script: How I Produce my Cycling Videos.

in Linuxlast month

The only video editing software/app I really enjoy using is CapCut (free version) on my Samsung Galaxy A33 mobile phone, it's fun and really easy to use to create professional clips. When it comes to cycling video's I prefer not to use the phone, it is way too important to be damaged during any sort of rigorous outdoors activity. Here's my gear:-

Sony FDR-X3000Ulanzi MT-44 Tripod
20241019_161654.jpg20241019_161958.jpg

Below images show the recording setting I use on the Sony and also the type/size of microSD card that's gives me 2hours 45mins of video footage. I always take out 2x cards 2x Sony Batteries 1x Powerbank.

Sony SettingsMicroSD Card
20241019_162400.jpg20241019_162726.jpg

My computer is a common desktop, HP EliteDesk with the MX Linux Distribution (my favourite that I've now been using for the past 5 years)

When I do record an actual ride there is certain steps I use to ensure a decent video outcome.

Both batteries fully charged
Both MicroSD Cards newly formatted
Horizontally level the camera on the cycle mount
Recheck mount, is it firmly mounted and won't fall off due to vibration
Check for vibration noises, this tends to come out badly in video
... you will hear it in the sample video on this post
Clean the lens (the number of blurry videos I've made is a SIN!)

Now the riding part, here too I am mindful I'm recording and think of the following

Record in small burst's, no longer than 5mins if possible unless
... you want to record the whole ride (which honestly can be boring to watch)
Find smooth paths with long corners, avoid bumpy grassy areas
Lighting is important too, never recorded at night (maybe I should at least once)

Here's an example video I just made from a older ride

I thought I'd show this first before the boring part of this post :-)

Bash Scripting (Open Terminal in Folder)

Cutting clips from orginal recording

ffmpeg -ss 00:01 -i C0001.MP4 -to 0:10 clip01a.mp4

ss is the time on the recording where to start the cut
i is recording filename (case matters)
to is duration you want to keep

Note: I like to make all my clips with a duration that is in multiple of 5sec. The 1st clip needs to be 10sec, adding text to 10sec+ clips looks better.

Adding text to a clip

ffmpeg -i clip01a.mp4 -vf "drawtext=fontfile=/path/to/font.ttf:text='My Text':fontcolor=white:fontsize=36:box=1:boxcolor=black@0.4:boxborderw=5:x=(w-text_w)/2:y=h-th-16:enable='between(t,1,6)'" -codec:a copy text01a.mp4

OMG !!! I hear you scream LoL but to me it's straight forward

i is input clip (the one you made from above)
just change MyText to what you want to display on video
fontfile, fontcolor, fontsize, boxcolor, boxborderw - have a play
between, 1,6 means at timestamp 1 sec display text 6 stop here

Merging Clips into a Single File

mencoder text01a.mp4 clip02a.mp4 text03a.mp4 text03b.mp4 -ovc copy -oac pcm -o RIDE001.mp4

This too is straight forward and easy to implement. At this point you can see I have a specific way I name my files.

C0001.MP4 : Action camera generated
clip05b.mp4 : second clip taken from C0005.MP4
text11a.mp4 : text has been added to clip11a.mp4 which was clipped from C0011.MP4

This way I can keep a track of what I'm doing and making modification to the final merged video becomes easy.

Finally, I make a 30sec video (strava limit), upload to phone, using capcut add music then export as 720p. This is the only way I upload a video Strava accepts.

MX Linux is my JAM, I'm using it 24/7 and totally suits all my needs. When it comes to creating BASH scripts, I only do it like 4hours over a year, it's just fun finding ways to do things, Necessary? NO, Linux has Video editors built in and downloadable but for me I like to dabble every now and then.

The HARD part is going on a ride!


GPS Tracking and Display produced by Strava on Samsung Galaxy A33 5G Phone.
Photos/Videos were taken from Sony FDR-X3000 Action Cam/Samsung Galaxy A33 5G Phone.

  • with every post comes experience, as we all strive to do better.
  • curate/up-vote, let's encourage/reward and inspire each other.
  • as always, thank you for viewing my post.