mltframework / shotcut

cross-platform (Qt), open-source (GPLv3) video editor
https://www.shotcut.org
GNU General Public License v3.0
11.05k stars 1.14k forks source link

Bug in transition #798

Closed sztigv8 closed 4 years ago

sztigv8 commented 4 years ago

Windows 10 x64 Shotcut version 19.10.20

It makes video jump and audio repeat on transitions

To Reproduce

It can be easily verified on Windows 10 machines by opening my MLT XML Download files to the desktop and replace “put_in_name” in the XML file with “user_name” Its in 4 lines ---- line 7 , 22 , 56, 74

http://www.mediafire.com/file/eusliz2guuzgbfj/Shotcut.mlt/file http://www.mediafire.com/file/k86zmjdswnega0d/export.mp4/file http://www.mediafire.com/file/689opdecbk2gav7/Bumper.mp4/file http://www.mediafire.com/file/gewua4orku1phg7/Shotcut_bug_preview.mp4/file

ddennedy commented 4 years ago

I see the problem in your project, but I do not reproduce it following your steps. Looking at the XML of your project I see the second clip in the transition is too short for the transition:

    <track producer="producer3" in="00:00:00.240" out="00:00:00.980"/>
    <transition id="transition0" out="00:00:00.920">

0.980 - 0.240 = 0.740, but you can clearly see the transition is 0.920. (Actually, to get duration we need to add one frame, 20 ms, but that is not too important now.)

Also, the first clip in the transition is here:

    <track producer="producer2" in="00:00:10.440" out="00:00:11.360"/>

And 11.360 - 10.440 = 0.920. So, the size of the first clip is correct.

But following your steps, I do not reproduce this problem (hard to see/hear the repeats on your bumper, so I look at the times in the XML since your files are seeking okay).

    <track producer="producer3" in="00:00:01.000" out="00:00:01.980"/>
    <transition id="transition0" out="00:00:00.980">

See, it is correct. So, the question is how did you get it this way? By resizing the transition? I tried doing that but was unable to reproduce it.

    <track producer="producer2" in="00:00:08.280" out="00:00:09.580"/>
    <track producer="producer3" in="00:00:00.240" out="00:00:01.540"/>
    <transition id="transition0" out="00:00:01.300">

9.580 - 8.280 = 1.300 1.540 - 0.240 = 1.300

Is this a problem that you can repeat from starting over, or is it just in this project?

sztigv8 commented 4 years ago

After further test I believe Ive found the root of the problem. I think the way Shotcut handles transitions is at fault here. Im not a programmer so I cant figure out whats going on there under the hood but Ill try to explain it by comparing shotcut to other video editing applications.

Suppose we have 2 clips containing 6 frames each

If I were to blend them in some other NLE my transition would be limited by the duration of each video so maximum duration would be 6 frames. In shotcut it is possible to make it 12 frames long and thats problematic because you cant make a 12-frame clip out of a 6-frame clip without repeating frames. And this is exactly how melt handles it, it repeats frames.

Heres how it works in other NLEs

GITHUB-1

Its simply impossible to go over the red lines because if you did so, you’d end up in a place where no video is present. If you try to do it in say Final Cut or DaVinci Resolve itll give you a warning that handles are too short to create such transition. Shotcut lets users to go over the red line and to compensate for being in the no video area it fills it up with repeated frames (I believe Premiere used to deal with it that way back in the old days). When its done from left to right it freezes the last frame of the first video, when dragged from right to left it starts the second video from the top and when it gets to the actual start of the video it repeats it again.

GITHUB-2

GITHUB-3

To answer your question I can reproduce this behaviour time and time again. No need to resize it, all I need to do is to make it longer than the actual overlap. Please view my screengrab video to reproduce it (3 xmls from this short session in the zip file).

So its particularly strange why this behavior occurs in the first instance as the video gets trimmed by exactly 1 second which is the transitions duration so in theory Shotcut should have enough handle to cover the entire transition without making any repetitions and it seems the values are correct in the XML file. The shift might have something to do with the fact that in/out points are expressed in time units as opposed to frames possibly?

<property name="shotcut:transition">lumaMix</property>
    <track producer="producer5" in="00:00:09.400" out="00:00:10.360"/>
    <track producer="producer1" in="00:00:00.000" out="00:00:00.960"/>
    <transition id="transition0" out="00:00:00.960">

But they are incorrect in XML 2 and 3

<property name="shotcut:transition">lumaMix</property>
    <track producer="producer5" in="00:00:07.480" out="00:00:09.360"/>
    <track producer="producer1" in="00:00:00.000" out="00:00:01.360"/>
    <transition id="transition0" out="00:00:01.880">

the difference gets more obvious with the increase of the length

<property name="shotcut:transition">lumaMix</property>
    <track producer="producer5" in="00:00:04.120" out="00:00:07.440"/>
    <track producer="producer1" in="00:00:00.160" out="00:00:01.280"/>
    <transition id="transition0" out="00:00:03.320">

Changing duration to the correct value doesnt make any difference as the in/point are clearly out of range of the clip so in my opinion the mechanics of creating transitions should be improved, transition duration should be limited by the handles length.

http://www.mediafire.com/file/mlwf7s81o10ft44/github.mp4/file

http://www.mediafire.com/file/e9afhmxzuyr6xau/bug_rep_0123.zip/file

http://www.mediafire.com/file/ug4p10ddx5ue8qu/testfile.mp4/file

http://www.mediafire.com/file/5wjp434vftp7fl0/BumperTT.mp4/file

ddennedy commented 4 years ago

Yes, transition by trimming should be constrained by the natural limits of the footage. It is very bad when going from right-to-left because the engine does not repeat the first frame. What is interesting is that I have constrained it when you are resizing a transition.