Any plans for gpx location/speed overlay feature?

I went too far with arbitrarrily and sent the wrong idea, I don’t mean to instantly change something, I mean any text field in the QML. I basically want this: “gps_start.text = filter.get(‘gps_start_text’)” any time filter UI is refreshed but can’t seem to make it work. For some reason I never thought of just doing a test “gps_start.text =‘test’” which I now see works so turns out I’m doing something wrong with the assignment.
Is it possible to print debug text from the qml?

Yes, this is exactly what I’m trying to do but I think this particular action only makes sense in a GUI application, so yes, it would fail the cmd test. It is a hint on which the user can act or not. Basically instead of trying to figure out the exact time difference between gps and video and straight out input it, I try to do a “close enough” guess by pressing this button and after this the user can adjust +/- to get perfect sync.

I disagree about the melt suggestion, I gave it a try but having to input my properties manually is really not ideal, it seems to just slow the process down. I need to give a bunch of initial attributes just for the text to allign and not be black on black. This is the melt output with the gpx file loaded:

1 Like

console.log(string)

2 Likes

It takes a little extra time to learn to use the parameters initially. But after you have entered the command once, you can simply press “Up” + “Enter” to re-run the same command again. Surely that is much faster than waiting for Shotcut to load and clicking the actions to open a clip, add a filter, etc.

I am giving you this melt advice because as some point you will submit a pull request for code review and if your contribution does not work properly in melt you will have a bunch of potentially difficult review comments to resolve by changing your design. For example, you should pick good default values for the text colors so that the filter does not result in black on black.

1 Like

I notice that the box with the text is made darker than the image it overlays.
That is good for white text, but if the text will be black, the box should highlight lighter than original.

Is the capability available for the box to be a less-contrast of the original, pulling all the colors towards neutral grey while still showing through the image?

1 Like

Touché. I see your point and will use melt for testing at the end.
But at this point it is not very useful as 90% of the remaining work now is UI/Shotcut related. The mlt part is somewhat done (well, I do want to add a few more features like gps path smoothing, fixing display for gps fields that only appear every x seconds, supporting .kml files - all of them internal, not linked to any property), so I pretty much change stuff in .c to make the QML work.

All of the usual text settings from Text: simple filter are available, that’s just how the melt renders the default values from the file. Which btw, are identical to “Text: simple”'s defaults :slight_smile:

This is what I see in shotcut while debugging (white text with black outline):

1 Like

Yes, that is much nicer.

1 Like

No. The color options are:

  • fgcolor
  • bgcolor
  • olcolor

https://mltframework.org/plugins/FilterText/

1 Like

In melt, you would add parameters: bgcolor=0x00000000 fgcolor=0xffffffff olcolor=0x0000000ff

1 Like

Hey, I am pretty much done with the filter and just have a final round of questions before trying to finish everything up and try to remember how to make a pull request on github:

Questions for the .c file:

  • can the filter_process call ever be interrupted if it takes too long (and realtime option is used)? (the initial file parsing can take from 10ms to 200ms if it’s very large, further calls are <1ms per frame but the initial call is the important one)
  • I moved all the filter’s static data to a private struct, can this data be accessed from another filter if needed? (I want next to try and make some graphics - in another new filter using Qpainter - using the already processed data and options from one instance of this filter)
  • I added a filter->close = filter_close; in init which frees my data but I can’t seem to actually trigger it. I put a mlt_log in it but it doesn’t print at all, and also when looking at task manager’s ram usage, it actually seems to go up when deleteing the filter in shotcut) - I know this question would be way easier to answer if you saw the code but is there something obvious I’m missing?
  • I have a lot of comments through the code, mostly useful as the file got really big, but I see most other filters have very few explanations in them. Do I need to clean them up or it doesn’t matter? Same question for mlt_log_* calls (now commented out)

For the .qml:

  • I don’t undestand what’s the purpose of filter.blockSignals and when it’s needed, it sound like it blocks ui changes from code when user edits them or something? I actually had a lot of trouble undestanding the patterns QT uses so I expect a lot of comments/issues in the pull request for the code I have now.
  • can I make presets with values for the main textArea (it’s coded exactly the same as in dynamictext)? I don’t mean just the default one that comes from filter_init, I want to add a “simple/generic” preset and a “all available fields” one.
  • I haven’t managed to get a Connections thing going that satisfies my use case: I basically want to update a text field in UI just one time after the gps file is selected and processed. I need a “onMyFilterPropertyNameChanged” trigger. If I use the target:producer it will update it but only if playing the video/moving playhead. At this point I just let it update if the Component.onCompleted is called and also put a small “refresh” button. Can I do something like this? I’m not sure if it’s even worth it to go further with it as it will just refresh itself when redrawing the ui.

And one question about encoding time: there seems to be a halve in number of cpus used for encoding when I apply my filter. Can I do something to enhance this? It seems to be linerly decreasing to the number of filter instances active at the same time so if video alone uses ~100% cpu (1 min sample, encode time: 27s), video+1filter stays around 50% (encode time: 52s), video +6filters ~20% cpu (=3min encode), video+24filters ~10% cpu usage (encode estimate: ~10min).
The exact same thing seems to happen with text:simple filter alone.

No, but we usually avoid this function for heavy operations and put it in get_image() even if it is for one time.

I moved all the filter’s static data to a private struct, can this data be accessed from another filter if needed?

No, whatever you want to share with another filter should be put into properties whose name is prefixed with the name of your filter followed by period.

I added a filter->close = filter_close; in init which frees my data but I can’t seem to actually trigger it.

There are many things that can add a reference to your filter including frames that pass through as well as Shotcut. This is easier to test from melt.

I have a lot of comments

That is fine.

there seems to be a halve in number of cpus used for encoding when I apply my filter. Can I do something to enhance this?

Not much except ensure your filter works with Export > Advanced > Video > Parallel processing. Surround critical sections within your get_image function (where you are changing any filter state as well as possibly things in Qt) with calls to mlt_service_lock() and mlt_service_unlock(). You do not need this in any of the other callback functions. You need to protect against not only crash but also image integrity. Please also be aware that when using this frames may be processed slightly out of sequential order.

Any time you set a filter property in your QML code, it is going to fire off filter-changed signals. A lot of filter UIs need to update their controls whenever the filter changes (it could have been changed by a keyframe animation). There are a few different cases where you need to block changes, and these are added usually in reaction while testing - once you realize something is happening you do not want. One case is when we use filter properties to communicate between UI and VUI. You can also use it to simply prevent the UI from updating frequently while setting many properties such as when creating the stock presets.

can I make presets with values for the main textArea

Yes, Text: Simple does. When you call filter.savePreset() you can specify which parameters to include.

I need a “onMyFilterPropertyNameChanged” trigger.

Any time you set a filter property in the QML code, it is going to trigger a frame refresh. This will call a onPositionChanged on a Connection { target: producer }. However, this is not available from within the MLT filter. There is a MLT event for when a property value changes, but this is not available to QML. This is a very high frequency event that I do not want to expose to QML. You can use a QML Timer to poll the change at a low frequency like every 500 ms.

I am very lost on the get_image call, I couldn’t even get it to a state where shotcut wouldn’t crash when using my filter - I would rather skip this part if it’s not very important. The usage in other filters is pretty complex and I don’t understand how and when the get_image is called and it’s relationship with filter_process (is it done before/after/in parallel?). The current code in filter_process is pretty stable and splitting it between get_image + filer_process sounds messy.

I couldn’t find any example of this, can you point me to a filter that does this? I also don’t understand how it would deal with multiple different filter instances.
And does this mean I should have used this method from the begining instead of the private struct?
Can I just share the address of the pointer of the private struct as a property?

From what I can see, Text: Simple only saves non text properties (size, alignment, etc) in presets. I tried setting the argument to something but couldn’t make it work at all. I decided to skip this idea and just go with the most likely/common text as the default without other presets (it would just make it confusing anyway).

A timer is perfect. I didn’t know qml had timers. it now updates very nicely.