Counter with Mouseclick

I need a counter for my badminton-training-tips like i found in this post.
Bad that is was closed.
In some badmintonstreams like this i wish to count correct strokes and skip missed strokes.

I wish to use only shotcut for showing a counter, that counts numbers when i maybe click left with the mouse.

The html-code of jonray or Elusien seems to do it, but i don´t know how to use in shotcut.
The text-splitting of MusicalBox is is too time-consuming for me, because I want to count about 30-40 times per video, and that’s for dozens of videos.

Is there any way to use a click-counter in shotcut by not using externel workarounds?

1 Like

Hi @thegrobi - I can’t see how this could be done directly in Shotcut, but today I amended @elusien’s and my HTML code (The main clever code was written by @elusien - I just added a few extras, with a bit of help from Gemini AI…)

Anyway, it’s now more user-friendly.
Here’s how it works in action. I used a badminton game as an example, in which the action was VERY fast, so I haven’t clicked the counter precisely enough in places…

Here’s the result in Shotcut. It was very quick to do.

Here is the amended code:

Click counter with embedded video - elusien and jonray.zip (1.8 KB)

Please read the instructions first, though - they are quite specific.

HTML Counter (Click or Spacebar Activated)

Code originally by elusien, adapted by jonray

Instructions

1. Prepare your folder

Create a folder and include:

  • The HTML file
  • A copy of your base video, renamed to “video-01.mp4”.
    • Note: You can use a different name or format (like .MOV), but you must update the code in the HTML file to match.

2. Launch the Counter

Double-click the HTML file to open it in your browser.

  • You will see the video player with your video loaded.
  • Beneath it is a counter with black text on a white square.
  • Tip: You can change the colors and fonts in the HTML code, but it is easier to adjust size and position later in Shotcut.

3. Screen Recording

Use an external program to record the screen. Recommended options:

  • ShareX (Easy to use)
  • OBS Studio (Advanced)
  • Windows Snipping Tool or Windows Game Bar

Tip: Record the full width of the screen to ensure the counter remains high-quality and avoids pixelation in Shotcut.

4. Record the Action

  1. Start the video playing.
  2. Increase Counter: Click or press [SPACEBAR].
  3. Decrease Counter: Press CTRL + CLICK or CTRL + [SPACEBAR].
  4. Reset to 00: Press CTRL + BACKSPACE.
  5. Stop and save your screen recording.

5. Final Editing in Shotcut

  1. Place your original video on track V1.
  2. Place your screen-recorded counter on track V2.
  3. Add a Blend Mode filter to V2 and set it to “Hard Light” (this makes the grey background transparent).
  4. Add a Crop: Rectangle filter to isolate the counter.
  5. Add a Size, Position & Rotate filter to place the counter where you want it.

Note: Ensure the two videos are aligned accurately on the timeline so the counter matches the action on screen.

DONE!

2 Likes

Dear @jonray,

You’ve put in so much work and helped me out a lot.
I think that’s extremely kind of you.
I managed to do it following your instructions and the modified code.
I used PicPick as a screen recorder.

Unfortunately, in my opinion, it’s relatively time-consuming to do this for several dozen of streams:

  1. To record parallel to the video, I have to either start the video first or start recording. This leads to a pause, which later has to be cut precisely in Shotcut.

  2. I only want to count the correct strokes. Not those that don’t fly over the net or out of the court, or where the player doesn’t even hit the ball.
    This happens relatively often in my specific streams. That is the challenge of this exercises. Then I often make a click in the recording that I unfortunately have to undo. This happens often, if to count very fast. Increase/decrease is helpful, but in a recording not the perfekt solution.
    A recording is relatively inflexible for this, compared to editable text.
    For slow counting (1 in 5 seconds) it is easy to work with.

The perfect solution would be timer text (which already exists in Shotcut), but not showing the elapsed time or frames, but a manual counter.

1 Like

Hi @thegrobi , it was no problem to amend the HTML, in fact, it will help me in future projects. (I make instructional music videos with the notation on screen, and it’s a handy tool for me to add counter numbers to bars (measures) of the music as it plays - so I will use it myself).

I understand that recording a screenshot is not the perfect solution and if mistakes are made with clicking while recording it’s hard to rectify, although it would be possible to edit the screenshot video by splitting and moving the numbers frame-by frame on the timeline if needed…

Until if and when a counter feature like this is added I guess the only other solution is to add numbers on a frame-by frame basis.

I had a go at myself - I made a folder of numbers 1-40 (PNGs with transparent backgrounds). This was very quick to do, with a combination of Shotcut keyboard shortcuts and a quick automated Auto Hotkey script I wrote - it took minutes.

Feel free to use them if you like. If you have lots of videos, though, yes, it’s going to be tedious! Here’s a short demo I just made. I put all the numbers on the (hidden) top track, advanced the video frame by frame, and pulled the numbers down when required.

Counter numbers incremental 0 to 40 with transparent background.zip (943.5 KB)

My quick demo:

1 Like

Hello @jonray,

Thank you again for this great new idea.
Placing the counter clips on two tracks can actually reduce the amount of work needed.

Why do you think it is advantageous to use PNGs instead of text clips 1-40?
Text clips could be edited retrospectively, for example:
1, 2, 3…
or:
1 Correct stroke, 2 Correct stroke, 3 Correct stroke…
or for you:
1 measure, 2 measure, 3 measure…

1 Like

I have now implemented a stream with text clips (instead of PNG-clips) on two tracks:
Track V6: Text clips 1, 3, 5, 7, etc.
Track V5: Text clips 0, 1, 3, 5, etc.

I will copy and paste these tracks for the next similar practice streams. Then I will adjust the clip lengths to the correct badminton strokes.
The editing time required for 1 minute of video is approx. 10-15 minutes.
That is for now okay to me.

@jonray Thank you very much for the idea of 2 tracks instead of 1.

I will upload this example in a few days on youtube and show it then here.
This streams are only for Youtube-shorts and instagram-Reels. So i don´t wish to invest much worktime for it.:stopwatch:

1 Like

Good point! To be honest, shamefully I hadn’t watched @musicalbox’s great tutorial before I posted!. Text clips are fine!

Having said that, making your own PNGs might be advantageous because you can add a border, or other design, and maybe custom positioning, to your counter. Depends on how much time/effort you have available to put into it!

To go even further, you could also make a short animated MOV when the numbers maybe “bulge” (ie enlarge then contract) - like in this demo showing short examples of one of my recent music videos:

… however, this may be overkill! :joy:

Good idea, and glad your editing will now be a little less tedious!

Thanks, I’d like to see an example of the result!

Before i will upload the first stream on youtube i show a sceenshot of the editing in shotcut.

This is the look, when the player works.

This is the look, when the result is shown.

1 Like

Looking good, @thegrobi . I would like to see the final video if you’d like to post it!

Here is the first video.

More will follow on YouTube and Instagram in the next few days.
It’s going to be a competition:
Anyone who manages to hit an average of under 1.55 seconds will get a free lesson from me.
I hope, the rules are not to complicated. :roll_eyes:

This is the second badminton competition I’ve organised using Shotcut.
Here you can see all the streams of the first competition.

Here you will see all the streams of this new competition.

1 Like

Nicely done :+1:

I see your average is 1.73 sec
If some manages to get an average under 1.55 sec, shouldn’t he/she give YOU an free lesson? :wink:

That’s not me in the video scoring an average of 1.73 seconds.
I can probably only manage around 2.5 seconds. :roll_eyes:

You’re right:
If one of my students gets under 1.55 seconds, I’ve trained them really well and should get a gift. :trophy:

1 Like

Very nice, @jonray, thanks for continuing to work on this! As you may recall, I’m the one whose original plaint three years ago motivated you and @eliseurm to come up with that great counter html-code. I use it often to this day, and I certainly have not forgotten who came up with it! Very much obliged.

But what, exactly, have you changed now? I see the decrement and reset features via key combinations. Anything else?

I still wish someone could come up with an automated counter. I use the html counter almost exclusively to prepare my high-rep calisthenics videos. While it works a treat, it’s still time-intensive to work through 100 plus reps of push-ups, for example. I record the browser screen using Techsmith’s free Capture app, which continues to work well for me. But 100-plus push-ups takes up to ten minutes or more, and I have to hit the spacebar for each of those reps and try not to get distracted or slip up halfway through. Then I import the video into Shotcut as V2, size, move, and colorize, and add transitions using @MusicalBox’s sweet horizontal-transition macro. I speed up the middle 80% about 8x so the entire video is on the order of two-and-a-half minutes long: reasonable for Instagram or YouTube, for example. The whole operation takes me a half-hour if I’m lucky, often more.

Ideally, somebody one day might come up with an automated counter that uses motion detection. Set the parameters for the target area in the video and for the incrementing choices, and let ‘er rip! That would be superb.

Thanks for all the help here on this and over the years! And Happy New Year.

Best regards,
/dr

1 Like

@thegrobi Instead of using @jonray and my HTML solution, why not try this:

  • Put the video on V1;
  • Put the BLACK background with “Hits” on track V2;
  • Play the video, Pause it when the player does a “hit” and set a marker, repeat doing this to the end of the video;
  • Position the playhead to the first marker (hit) and create a text/rich-text clip on V3 that has the number “1” and copy the clip;
  • Position to the next marker (using the “Markers” panel) and paste the clip, then edit the text to say “2”;
  • Repeat for all markers (hits) incrementing the number each time.

I suspect this will be faster than the current workflow you use.

2 Likes

Thanks @Elusien,
I had actually already thought about the fact that it should be possible with markers.

However, I had never worked much with markers in my previous videos. I will try out the markers. Either exactly as you describe, or at least to make it easier to find positions and then complete it with the previous 2-track text solution.

I will share my experiences.

1 Like

This is a good idea. How about instead of pausing, run the video, and press M continually each time a hit is made (in other words, creating markers “on the fly”)?

An advantage of this is that if you make an error, the markers can be moved later to fine-tune it. I tried it, of course, making lots of mistakes. Practising it a few times would reduce the errors :wink: :

1 Like

This is almost the solution I was originally aiming for:

I wish to use only shotcut for showing a counter, that counts numbers when i maybe click left with the mouse.

  1. I set the markers by pressing the M key while playing the video in Shotcut.
  2. I deleted incorrect markers (shuttle not hit) using the Strg+Shift+M keys.
  3. I adjusted the text (1 hit, 2 hits, etc.), which was already spread across two tracks from a previous Shotcut session, to the markers.
  4. I checked the video several times in between to make sure that only the hits were counted.

Conclusion:
The editing did not work (for me) significantly faster than without markers (due to multiple checks), but it still comes very close to my original wish. :fu:

1 Like

Hi @thegrobi, glad you found an acceptable solution!

Hi @spamless, I remember your energetic workout videos! I got exhausted just watching them! :rofl: No problem to help! It was @elusien (master coder :wink: ) who provided the working code. I just changed the layout a little.

I added an embedded video player which appears on screen so you can run the video within the HTML file and click to increase the counter. Actually that idea came about from an idea by another forum member, @musicalbox, in a previous HTML project, so it was another Shotcut forum collaboration.

I also added SPACE as an alternate to clicking, CTRL + SPACE (or CTRL + Click) to decrease the counter, and BACKSPACE to reset the counter.

Click counter with embedded video - elusien and jonray.zip (1.8 KB)

Interesting, I hadn’t heard of that, I will investigate.

Pleasure, and Happy New Year to you, too!