Bug 363734 - Incorrect frame rate conversion
Summary: Incorrect frame rate conversion
Status: RESOLVED NOT A BUG
Alias: None
Product: kdenlive
Classification: Applications
Component: Video Display & Export (show other bugs)
Version: 16.04.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-31 09:50 UTC by Marcus Sundman
Modified: 2019-04-25 01:19 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
VFR example video (1.12 MB, video/mp4)
2016-05-31 09:53 UTC, Marcus Sundman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Sundman 2016-05-31 09:50:46 UTC
If the input file's frame rate does not match with the project's the frame rate is converted, but not correctly.


Reproducible: Always

Steps to Reproduce:
1. Add a clip with a different frame rate.
2. Notice how the frames are not the right ones.

Actual Results:  
The 2nd frame in the example video is shown too early and for too long.

Expected Results:  
The 1st frame should be shown for 1000ms, the 2nd for 993ms, etc

Example video where each frame shows the timecode when that frame starts: https://drive.google.com/file/d/0B2GO5RdsrTircjJHc01ZbEpYckk/view?usp=sharing
Comment 1 Marcus Sundman 2016-05-31 09:53:39 UTC
Created attachment 99281 [details]
VFR example video

Each frame shows the time code when that frame starts.
Comment 2 Jean-Baptiste Mardelle 2016-05-31 18:41:24 UTC
Hi, thanks for your report. 
It's actually hard to understand the exact problem from your description.
In your expected results, you say: "The 1st frame should be shown for 1000ms, the 2nd for 993ms, etc".
That is quite puzzling... Can you give more details about what is the framerate of your video clip and what is the framerate of the project ?

Does this framerate issue appear in Kdenlive's monitor, or in rendered files, or both ?
Comment 3 Marcus Sundman 2016-06-06 16:13:33 UTC
As I wrote, each frame in the video displays the timecode when that frame starts. The video is VFR. The 1st frame is 1000ms long, the 2nd frame (which starts at 00:01.000) is 993ms long, the 3rd frame (which starts at 00:01.993) is 986ms long, etc.
Comment 4 Marcus Sundman 2016-06-06 16:14:25 UTC
Oh, and the issue is present in both the monitor and the final output.
Comment 5 Marcus Sundman 2016-06-06 16:18:43 UTC
And it's there both in 15.12 and 16.04
Comment 6 Wegwerf 2017-02-05 10:46:28 UTC
As no-one seems to understand what the issue really is (me neither), and I strongly suspect it to be related to ffmpeg and MLT, and there has been no progress here as the OR did not attempt to clarify to the exte6that devs underst6the issue, I'm closing this. Please refrain from reopening this report unless you can clearly demonstrate and explain what the perceived bug really is (the screenshots don't help) and what it's clearly a bug in Kdenlive, and not MLT or ffmpeg. We expect out reporters to help us, so please refrain from creating unnecessary load. Thank you very much for your cooperation.
Comment 7 Marcus Sundman 2019-04-25 01:19:28 UTC
(In reply to Wegwerf from comment #6)
> As no-one seems to understand what the issue really is (me neither), and I
> strongly suspect it to be related to ffmpeg and MLT, and there has been no
> progress here as the OR did not attempt to clarify to the exte6that devs
> underst6the issue, I'm closing this.

How did I not clarify it? What is unclear?

> Please refrain from reopening this
> report unless you can clearly demonstrate and explain what the perceived bug
> really is (the screenshots don't help) and what it's clearly a bug in
> Kdenlive, and not MLT or ffmpeg.

I can't be sure in exactly which module the problem is, but I can describe the problem.

In every video each frame is shown for a specific amount of time. Let's say I have a 2 second video with a constant frame rate of 10 fps. (I.e., there's a total of 20 frames, each of which is shown for 100ms.)
Now, let's load this video into a kdenlive project that uses a framerate of 30 fps.
We still want every input frame to be shown for 100ms. Since every project frame is ~33ms each input frame should be shown 3 times in a row. (The output should still be 2 seconds, which at 30 fps means 60 frames, and the original 20 frames should be stretched out to fill those 60 frames, meaning each input frame becomes 3 output frames.)

With me so far? I don't know how to make this any clearer. To me it seems very, very simple. 20 frames in, 60 frames out, so each input frame becomes 3 consecutive output frames. I really, really hope that this is clear now. Please!

Now, the problem is that kdenlive does not distribute the input frames properly into output frames. Let's name the 20 input frames above A, B, C, D, ..., S, T. So if the 10 fps input is ABCDEFGHIJKLMNOPQRST you'd expect the 30 fps output to be like AAABBBCCC...RRRSSSTTT (or at most with an 1-off rounding error caused by the first and/or last frames to start/end at the halfway point, like AABBBCCC...FFFGGGGHHH...MMMNNNNOOO...RRRSSSTT).

However, kdenlive does something quite random, like ABBBBBBCCDDDD... where several frames are more than 1 frame off where they should be.

In other words, while in the original video each frame (A, B, ...) was 100ms long, in the output the frames are shown for very varying lengths of time. Some become too short, some too long.

I made a variable frame rate video where each frame shows the total amount of time that has elapsed before that frame starts. So, there has been no time before the 1st frame, so it shows 0:00.000. The 1st frame lasts for exactly 1 second, so the 2nd frame will show 0:01.000. The 2nd frame lasts for 0.993 seconds, so the 3rd frame will show 0:01.993. The 3rd frame lasts for 0.986, so the 4th frame will show 0:02.979.
Load this video into kdenlive, encode it, and look at the output. If kdenlive would respect the correct length of each frame then each output frame should show about the same time code as its location in the timeline. But they do not.