Any plans for gpx location/speed overlay feature?

I recorded my location with a gps smartwatch + some gopro video during my last vacation and was planning to use a tool called dashware to add the speed+location to the video but I realised this would involve double-encoding the videos with probably a lot of unused footage encoded for no reason so naturally I’m turning to shotcut to maybe skip a lot of the extra work involved for such a simple task.

Is anyone working on something similar to this?
If not, how hard would it be for me to contribute such a feature? I only have C experience, haven’t used Qt or MLT so far but from a high level perspective parsing a gpx file then deriving the speed and location doesn’t seem very complicated. Any hints on where I should start?

1 Like

I would say start by getting a C++ reference; Shotcut is, I am told, written in both C and C++, and the parsing you speak of is a classic example of where C++ shines.
(I made the C to C++ transition decades ago.)
In this case, the gpx file can be seen as a storage object, and thus coded as a class in C++, and each structured entry within the file is similarly conceptualized as a smaller storage object, and has its own class; the outer then containing a a header object and an array of timed entry objects, etc.
The form that Shotcut will need it will be similar, so you build an inverted pyramid of levels of abstraction of the data, and using multiple inheritance the tip of the pyramid is where the Shotcut data structure and the gpx data structure converge, in a multiple inheritance object containing multiple inheritance objects. Then the decode is all a matter of constructors.

This is how I handled a similar data-stream decode and encode between the ICAO network and the PRM radar system when we were building Hong Kong’s Chek Lap Kok airport. The object, class and multiple inheritance of C++ vastly simplified an otherwise complex and convoluted problem.

Thanks for the words, I was actually looking for more help in the shotcut-area of the feature, where to start: do I need the entire sdk, where do I put the backend, etc.
The gpx parsing is pretty straightforward.

1 Like

I’m glad for you that it is an easy data format.

Sorry, I can’t help you on Shotcut internals; I have not delved into those yet.

https://shotcut.org/howtos/contribute/

Look at the last section titled “Write Code” for SDKs and instructions. There are a couple of threads in the forum where people hit and resolved some issues. Search for “compile” or “compilation”.

Yes, that’s the tutorial I was trying to follow right now. I seem to fail at the last run step, with error: “ld.exe: cannot find -lmlt++”, do I need to install mlt separately?

This thread that has my exact problem seems to imply shotcut building under windows is not straightforward, is this still the case?

My (last lines of) error log are:

C:/Qt/Tools/mingw810_64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmlt++
C:/Qt/Tools/mingw810_64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmlt
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [Makefile.Release:792: release/shotcut.exe] Error 1
mingw32-make[2]: Leaving directory 'C:/Projects/Shotcut/src/build-shotcut-Desktop_Qt_5_15_2_MinGW_64_bit-Release/src'
mingw32-make[1]: *** [Makefile:45: release] Error 2
mingw32-make[1]: Leaving directory 'C:/Projects/Shotcut/src/build-shotcut-Desktop_Qt_5_15_2_MinGW_64_bit-Release/src'
mingw32-make: *** [Makefile:77: sub-src-make_first] Error 2
00:22:18: The process "C:\Qt\Tools\mingw810_64\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project shotcut (kit: Desktop Qt 5.15.2 MinGW 64-bit)
When executing step "Make"
00:22:18: Elapsed time: 02:01.

There is a small bug in this version of the SDK. To fix move the un-versioned libmlt.dll and libmlt++.dll into the lib subdirectory. I am preparing a new version of the SDK today to go along with the new release that fixes that, but you can make this simple change to move ahead quickly.

As for how to get started with your idea, it depends on how graphical you want to get. If you only need text, it can be easy. If you need to animation gauges and draw routes with or without a map, we are talking several orders of magnitude more difficult. If you use Shotcut much you quickly learn there is really nothing to handle non trivial 2D animation. Some people have done similar in a highly visual manner in the past using Shotcut’s HTML5 technology but that is no longer integrated.

If you are only interested in text, then there are not many patterns to follow in MLT or Shotcut for generating text. It is weak in the areas of timed text, subtitles, and captions. You can find in #resources where someone has created a tool to convert subtitles into Shotcut text clips. That is one approach. Another approach is to create a filter in MLT that decorates the frames passing through with properties whose names begin with “meta.” as these are accessible through a single instance of Text: Simple filter.

The best API we have for this is the QPainter API in the qt module. It would be really neat if someone used QT to build a generic graph/gauge filter in MLT that could be connected to arbitrary data (including GPS).

Thanks, that did it.

I’m thinking first step to be only live text, updated every frame (or data point from file). I’m not really into graphic design so gauges are definitely not planned, best I could probably do would maybe be a static icon with text near it. For inspiration I’m thinking the Timer filter could help a lot for the text, and the lut3d one for loading a file.
The meta approach is interesting as it would allow complete custom text from users. But I’m getting way ahead of myself here.

This looks very useful, not sure about drawing gauges but for now I’d be happy with a simple path drawn from the gps points on a transparent background (an actual map would be quite hard to bring in as it would probably require some api calls to an external map provider then synced with the drawing).


I do have one more question, can a filter have multiple on-video elements that can be moved/resized independently? Imagine two “Text: simple” filters but from a single filter - I’m thinking speed/total distance/elevation as separate output results from one single filter instance that can be moved independently on the screen.

What would be the disadvantage of using two filters? One filter for speed and one filter for elevation. There are currently no filters that provide multiple overlay objects. So that would be more effort/design.

Mostly, less cluttering and better organisation. 2 filters sound ok but 5 would start to get annoying to sync their settings.

I have a few more beginner Qt questions if you guys can give me a few hints:

  • how much of the code for a new filter should be manual copy-paste and then fiddle with the details and how much is it automated by the qt creator? I played around with the UI and using the designer view/form editor adds quite a lot of extra properties that are not in most other filters and makes the ui file quite large.
  • I see there’s some Shotcut.Button and also just Button, I assume the Shotcut.names are custom/specific implementations that Shotcut uses but in the QT creator project all Shotcut.names are marked red (Unknown component (M300)) so I’m missing all the smart stuff the IDE does, is this important to fix/fixable? does it matter?
  • after looking at the way things are organised in the project, for my intended filter I think I need to add these 5 files, is this correct?
    – in Shotcut\src\shotcut\src\qml\filters\ -> new folder with filter name + 3 files meta.qml, ui.qml and vui.qml
    – in Shotcut\src\mlt\src\modules\plus (or new folder in modules?) 2 new files: .c and .yml (is the yml also manual, or do I use something in qt creator to auto generate it?)
    – - probably add the new file into makefile

All of the QML and YAML should be created and edited manually. I use Qt Creator but never the Design view for QML. If you really want to use the Design view, then you need to figure out how to make it work with Shotcut’s QML code because no one else is using it.

If your MLT C code has some external library dependencies then it probably needs to go into a different module. Are you planning to mimic dynamictext? What about gpx parsing? If you want to use libxml2, then put it into the xml module. If you want to use Qt, then the qt module.

1 Like

Ok, manual editing makes sense, thanks.

As for the actual implementation I haven’t reached that point yet so can’t answer. I’m leaning towards dynamic text but I think I will start with a lower target (like just reading the lat/long and printing them on screen at the correct time) and build on top of what works.

You should basically plan the backend MLT plugin. dyanmictext shows how you can “drive” a text filter that does actual rendering without rendering it yourself. If you plan to render it yourself, you need to consider that library dependency as well. For example, I would reject a filter that uses Qt for text rendering but libxml2 for XML parsing as that is not really a sensible combination. Modules are typically divided based on dependencies and license: xml does not depend on Qt, and qt does not depend on libxml2.

Well this is getting frustrating, I’ve already spent more hours on technicalities than I planned to spend in total.

The frontend part gets (linked/compiled?)/added correctly in the project (-> I can get a completely new filter to appear in the Shotcut filter list as long as I use an existing mlt_service), but I don’t think qt creator even looks at the backend in \src\modules* .c files as I can straight up delete the content of the files for a filter and it still works correctly. Looking at what files are updated when doing a complete project rebuild, it seems like only shotcut core files are being compiled, and translations.

So what am I missing here?

Actually, let me ask a more specific helper question: if I want to change something in the dynamictext filter: instead of the default arg: “#timecode#”, let’s say we need to change it to “Hello world!” -> this is in “C:\Projects\Shotcut\src\mlt\src\modules\plus\filter_dynamictext.c” file. How would I do this? (keep in mind I can currently just delete the entire .\modules folder tree and the filter is still there in the built project from qt creator :confused:).

The instructions we provided only support building Shotcut and not its dependencies through Qt Creator. You can also build dependencies like MLT, but that is more work. You might to get that working on the command line first and then you can try to configure the Qt Creator MLT project to mimic the command line.

https://www.mltframework.org/plugins/FilterDynamictext/

I was hoping that isn’t the case.
Is it possible to avoid building the dependencies? Or is it mandatory for filters to be integrated into the MLT framework project then shotcut project only takes care of the shotcut-graphical part? If not, can you give me an example filter that’s shotcut-internal (so to speak) and I can look at?

There are no Shotcut internal filters by architectural design. Please read more: (the following page is found from our site map link at the top of this page)

https://shotcut.org/notes/make-plugins/

You will need to build MLT since that is where the processing will happen. In the past, I have successfully followed the instructions at the bottom of this page under “Rebuilding Dependencies”:
https://shotcut.org/notes/windowsdev/
You will want to install GitBash for that.

1 Like