Bug 456492

Summary: Copy and paste Motion Tracker keyframes does not work
Product: [Applications] kdenlive Reporter: Rodolphe <rodolphe.jantzen>
Component: Video Effects & TransitionsAssignee: Vincent PINON <vpinon>
Status: RESOLVED FIXED    
Severity: major CC: jb, jbishop2112, kde, motolo79, pierre.nerzic, snd.noise, stantheman74, talk
Priority: NOR    
Version First Reported In: 22.04.3   
Target Milestone: ---   
Platform: Flatpak   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: After clicking on "Import keyframes from clipboard"

Description Rodolphe 2022-07-08 20:27:50 UTC
Created attachment 150487 [details]
After clicking on "Import keyframes from clipboard"

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Applied Motion Tracking
2. "Copy keyframes to clipboard" from the Motion Tracker effect
3. "Import keyframes from clipboard" in the Transform effect of an element with the same time length

OBSERVED RESULT
Not all keyframes can be imported (see picture). Sometimes the "Out" bar can't be moved.

EXPECTED RESULT
All keyframes should be visible.

SOFTWARE/OS VERSIONS
Pop!_OS 22.04
MLT: 7.9.0
Qt: 5.15.5 (built against 5.15.5 x86_64-little_endian-lp64)
Frameworks: 5.95.0
System: KDE Flatpak runtime
Kernel: linux 5.17.15-76051715-generic
CPU: x86_64
Windowing System: xcb
Movit (GPU): disabled
Track Compositing: frei0r.cairoblend

ADDITIONAL INFORMATION
It also didn't work with the 22.04.2 version of Kdenlive, and with the AppImage.
Comment 1 talk 2022-07-22 06:50:29 UTC
Its the copy function that is certainly failing. I am not sure if paste is failing too because I don't see keyframes after copy. Some dimension values are changing, so i did expect to see keyframes.

Changing shape to Ellipse did not help. Import dialog box still showed 'Rectangle'.

OS: Kubuntu 20.04.4

Data on clipboard:
[
    {
        "DisplayName": "Rectangle",
        "in": 19426,
        "max": 0,
        "min": 0,
        "name": "results",
        "opacity": false,
        "out": 19606,
        "type": 9,
        "value": "19426~=825 196 152 124 0;19431~=828 197 152 124 0;19436~=827 196 152 124 0;19441~=827 195 152 124 0;19446~=830 198 152 124 0;19451~=842 207 152 124 0;19456~=857 219 152 124 0;19461~=868 239 152 124 0;19466~=877 262 152 124 0;19471~=879 277 152 124 0;19476~=879 282 152 124 0;19481~=880 283 152 124 0;19486~=881 282 152 124 0;19491~=881 282 152 124 0;19496~=879 280 152 124 0;19501~=876 266 152 124 0;19506~=865 241 152 124 0;19511~=850 223 152 124 0;19516~=836 205 152 124 0;19521~=827 194 152 124 0;19526~=823 191 152 124 0;19531~=823 191 152 124 0;19536~=825 189 152 124 0;19541~=827 185 152 124 0;19546~=829 179 152 124 0;19551~=831 176 152 124 0;19556~=830 174 152 124 0;19561~=828 172 152 124 0;19566~=828 169 152 124 0;19571~=830 170 152 124 0;19576~=834 171 152 124 0;19581~=838 171 152 124 0;19586~=841 171 152 124 0;19591~=844 171 152 124 0;19596~=848 172 152 124 0;19601~=853 173 152 124 0;19606~=858 174 152 124 0"
    }
]
Comment 2 Kenny 2022-07-23 04:23:43 UTC
The error is not always reproduced.
Sometimes importing frames works, sometimes only one frame is imported, sometimes several, but not all.

A project where only the first frame is imported: https://tempic.ru/error-tracker.zip (20MB)

The project from above has a video with a tracker; to reproduce the error:
1. copy frames from tracker
2. insert frames into title filter

Reproduce the error: https://youtu.be/VaMSG_8EUY0
Comment 3 stan 2022-08-06 09:02:26 UTC
I'm seeing the exact same bug, as shown in the youtube video in previous post above, but it's consistent, I've never gotten more than one constant point from my motion tracker, when I try to import keyframes from the motion tracker, to a transform of an icon that I want to move along an object in the video.

I'm on Arch Linux, (no desktop environment, using clipmenud as clipboard manager), my Kdenlive version is v. 22.04.2 and I've replicated the bug on the latest App Image 2022-08-05, build 301. 

Interestingly, just now, that I was confirming that the bug is still there, I first accidentally clicked the wrong effect to import to, namely a "crop scale tilt" effect (not sure motion tracking makes sense for that effect) on another track and clip, and then the keyframe import window did show non-constant graphs, and it looks like it did import keyframes.  

This inspired me to confirm (on build 301), that importing key frames from one motion tracker effect, to another motion tracker effect, on another clip, works.

For completeness, when I copy the keyframes, I end up with the following in my clipboard:

v. 22.04.2 & latest App Image 2022-07-18 (282)
[
    {
        "DisplayName": "Rectangle",
        "in": 1523,
        "max": 0,
        "min": 0,
        "name": "results",
        "opacity": false,
        "out": 1599,
        "type": 9,
        "value": "1523~=415 107 470 475 0;1528~=402 95 480 480 0;1533~=413 76 480 480 0;1538~=434 33 480 480 0;1543~=472 -19 480 480 0;1548~=542 -45 480 480 0;1553~=596 -54 480 480 0;1558~=650 -54 480 480 0;1563~=703 -36 480 480 0;1568~=726 -42 480 480 0;1573~=756 -52 480 480 0;1578~=772 -29 480 480 0;1583~=780 3 480 480 0;1588~=799 10 480 480 0;1593~=792 15 480 480 0;1598~=763 20 480 480 0;1599~=683 144 480 480 0"
    }
]
Comment 4 stan 2022-08-18 15:07:12 UTC
*** This bug has been confirmed by popular vote. ***
Comment 5 Pierre Nerzic 2022-09-03 08:43:26 UTC
Hi,

As far as I can see, it seems related to the timestamps of the keyframes. It looks like the import does not take "in" and "out" fields of the JSON to make the keyframes relative.

Because: I paste the clipboard into a text editor, then I edit every keyframe so that the timestamp is relative to 0 instead of "in", then copy it back to clipboard (^C), then I can import it successfully into the effect.

An example:
1) what I had into the clipboard after "copy keyframes to keyboard" :
>[
>    {
>        "DisplayName": "Rectangle",
>        "in": 420,
>        "max": 0,
>        "min": 0,
>        "name": "results",
>        "opacity": false,
>        "out": 570,
>        "type": 9,
>        "value": "420~=1649 179 453 263 0;425~=1619 185 453 263 0;430~=1586 190 453 263 0;435~=1563 197 453 263 0;440~=1540 204 453 263 0;445~=1525 213 453 263 0;450~=1516 222 453 263 0;455~=1511 225 453 263 0;460~=1504 220 453 263 0;465~=1497 215 453 263 0;470~=1492 212 453 263 0;475~=1481 213 453 263 0;480~=1462 212 453 263 0;485~=1427 213 453 263 0;490~=1380 206 453 263 0;495~=1323 201 453 263 0;500~=1262 196 453 263 0;505~=1195 193 453 263 0;510~=1124 180 453 263 0;515~=1055 175 453 263 0;520~=1008 168 453 263 0;525~=983 163 453 263 0;530~=964 162 453 263 0;535~=957 155 453 263 0;540~=972 138 453 263 0;545~=1009 125 453 263 0;550~=1058 110 453 263 0;555~=1115 97 453 263 0;560~=1182 102 453 263 0;565~=1259 121 453 263 0;570~=1336 144 453 263 0"
>    }
>]

2) what I changed manually (in, out and all the timestamps subtracted from in):
>[
>    {
>        "DisplayName": "Rectangle",
>        "in": 0,
>        "max": 0,
>        "min": 0,
>        "name": "results",
>        "opacity": false,
>        "out": 150,
>        "type": 9,
>        "value": "0~=1649 179 453 263 0;5~=1619 185 453 263 0;10~=1586 190 453 263 0;15~=1563 197 453 263 0;20~=1540 204 453 263 0;25~=1525 213 453 263 0;30~=1516 222 453 263 0;35~=1511 225 453 263 0;40~=1504 220 453 263 0;45~=1497 215 453 263 0;50~=1492 212 453 263 0;55~=1481 213 453 263 0;60~=1462 212 453 263 0;65~=1427 213 453 263 0;70~=1380 206 453 263 0;75~=1323 201 453 263 0;80~=1262 196 453 263 0;85~=1195 193 453 263 0;90~=1124 180 453 263 0;95~=1055 175 453 263 0;100~=1008 168 453 263 0;105~=983 163 453 263 0;110~=964 162 453 263 0;115~=957 155 453 263 0;120~=972 138 453 263 0;125~=1009 125 453 263 0;130~=1058 110 453 263 0;135~=1115 97 453 263 0;140~=1182 102 453 263 0;145~=1259 121 453 263 0;150~=1336 144 453 263 0"
>    }
>]
The latter can be imported without any trouble as keyframes into a transform effect.

I hope it will not be hard to repair :-)
My best regards,
Pierre
Comment 6 J B 2022-11-13 00:45:02 UTC
I have the AppImage 22.04.0 version, and got this bug for a scenario with two clips of equal length. I found I could import keyframes from the Motion Tracker on the one clip into the Transform effect on the other clip by first lengthening the destination clip (ie with Transform) to be longer than the source clip (ie with Motion Tracker). Then after the import, I just shortened it back to the original length.
Comment 7 J B 2022-11-13 14:36:01 UTC
(In reply to J B from comment #6)
> I have the AppImage 22.04.0 version, and got this bug for a scenario with
> two clips of equal length. I found I could import keyframes from the Motion
> Tracker on the one clip into the Transform effect on the other clip by first
> lengthening the destination clip (ie with Transform) to be longer than the
> source clip (ie with Motion Tracker). Then after the import, I just
> shortened it back to the original length.

It has to be substantially longer, not just a little bit. So in a case where the destination clip was already longer than the source clip to begin with, I had to lengthen it still further.
Comment 8 motolo79 2022-11-20 14:01:16 UTC
I found a simpler solution. Simply copy the motion tracking effect after you execute, paste onto the track where you want the keyframes to be returned, copy the keyframes from the motion tracking copy, not the main track, and paste the keyframes onto the effect. This fixes the bug that does not copy key frames.
Comment 9 motolo79 2022-11-20 14:54:07 UTC
Solution 

https://youtu.be/tukP9x0R1Ss
Comment 10 Jean-Baptiste Mardelle 2022-11-23 08:13:38 UTC
I can confirm the issue, thanks all. Working on a fix for the upcoming 22.12.0 release
Comment 11 Jean-Baptiste Mardelle 2022-11-24 11:26:34 UTC
Git commit 8647249503bcebf68be7d752e809a61e148795c4 by Jean-Baptiste Mardelle.
Committed on 24/11/2022 at 11:25.
Pushed by mardelle into branch 'release/22.12'.

Fix import keyframes broken.

M  +61   -23   src/assets/view/widgets/keyframeimport.cpp

https://invent.kde.org/multimedia/kdenlive/commit/8647249503bcebf68be7d752e809a61e148795c4