Bug 371849

Summary: audio file sounds "clicky" when on project timeline; affects rendered file
Product: [Applications] kdenlive Reporter: S. Christian Collins <s_chriscollins>
Component: Video Display & ExportAssignee: Jean-Baptiste Mardelle <jb>
Status: RESOLVED FIXED    
Severity: normal CC: admin, blackendwhite, fritzibaby, fun, lethal.logan, riku.seppala, snd.noise
Priority: NOR Flags: fritzibaby: timeline_corruption+
Version: git-master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: audio file for testing the bug
image showing the audio clicking
rendered audio from Kdenlive, full of clicks
Test the difference between combine and sum, produce wav results
sum with recent mlt
Video of Kdenlive glitchy audio with empty timeline and a jpeg

Description S. Christian Collins 2016-10-30 04:25:56 UTC
Created attachment 101893 [details]
audio file for testing the bug

1. Import the attached "test.flac" file into Kdenlive's project bin.
2. Play the clip in the Clip Monitor. You will hear a pure sine wave.
3. Now, drag the clip onto an audio track in the timeline.
4. Play the project.

Result: The sine wave now has a faint clicking noise that persists throughout the duration of the audio file. This clicking ends up in the rendered video file as well. The previous version of Kdenlive that I was using (0.9.6) does not have this bug.

This bug is present in the following configurations that I tested:
#1, via KDE Neon repository:
 . Kdenlive 16.08.2
 . KDE Frameworks 5.27.0
 . Qt 5.7.0
 . MLT 6.0.0

#2, via devel snap image:
 . Kdenlive 16.11.70 (devel)
 . KDE Frameworks 5.18.0
 . Qt 5.5.1
 . MLT 6.3.0

Both of these versions were tested on the following system:
 . OS: KDE Neon 5.8.2 64-bit (Plasma Desktop 5.8.2)
 . PC: HP Pavilion m6-1035dx
 . CPU/GPU: AMD A10-4600M APU with Radeon HD 7660G Graphics (using xorg radeon driver)
 . RAM: 6GB DDR3 800 MHz
 . Linux Kernel: 4.4.0.45-generic
Comment 1 S. Christian Collins 2016-10-30 04:27:55 UTC
I should also mention that this bug happens with every audio format I have tried: WAV, FLAC, OGG, MP3, and also at both 44.1 and 48 KHz sample rates. I haven't tried other sample rates.
Comment 2 S. Christian Collins 2016-12-06 08:32:21 UTC
Created attachment 102640 [details]
image showing the audio clicking

Here is an image comparing the original audio to Kdenlive's rendered audio. I have zoomed in to one of the faint, but constant clicking noises that Kdenlive adds into all exported audio. This bug is still present in Kdenlive 16.12-rc (tested using AppImage).

This bug has probably gone unnoticed by most as it is hard to detect in speech and many ambient sounds. But since my videos deal with the finer nuances of audio synthesis, the clicking is very audible in the pure waveforms featured in my videos, which unfortunately ruins the presentation of these sounds.
Comment 3 S. Christian Collins 2016-12-06 08:35:29 UTC
Created attachment 102641 [details]
rendered audio from Kdenlive, full of clicks

Here is what "test.flac" sounds like when rendered to WAV by Kdenlive. You can hear that it sounds very clicky.
Comment 4 Jean-Baptiste Mardelle 2016-12-06 11:05:15 UTC
I cannot reproduce with MLT's current git. Can you please try this in a terminal:

melt test.flac -consumer avformat:test.wav ac=1

Does the resulting test.wav file also has this click ?
Comment 5 Martin 2016-12-06 13:49:32 UTC
Is this the same problem?
https://github.com/mltframework/mlt/issues/124
https://github.com/mltframework/shotcut/issues/259

I can reproduce the crackling noise when rendering a full kdenlive project, but not when I just export stems or use melt with a single audio file on the command line.
Comment 6 Jean-Baptiste Mardelle 2016-12-06 14:25:29 UTC
Thanks for your feedback. I didn't follow the recent MLT changes related to audio mixing, but your issue might very well be retated to the issues you described.

It would be interesting to see if this artifact disappears if you replace "combine" with "sum" in the audio mix transitions of the Kdenlive project file (that does however require a very recent MLT git, as this was added 15 days ago).

I will look into it as we might have to switch Kdenlive's default audio transitions...
Comment 7 S. Christian Collins 2016-12-06 18:01:34 UTC
I tried the melt command suggested in comment #4, but this did not create any artifacts.

However, this does indeed seem to be related to the MLT issues posted by Martin in comment #5. Following the steps by ddennedy in the thread at https://github.com/mltframework/shotcut/issues/259#issuecomment-244806461 (this link will jump straight to his comment) solves the crackling issue, so it definitely seems to be related to the "combine" mixing method.

Interestingly, the rate of crackling also changes with project framerate. It sounds like MLT is chopping the audio up per-frame, but not re-combining the audio with 100% accuracy.
Comment 8 Abe 2017-01-07 09:21:55 UTC
> It would be interesting to see if this artifact disappears if you replace
> "combine" with "sum" in the audio mix transitions of the Kdenlive project
> file (that does however require a very recent MLT git, as this was added 15
> days ago).

Replacing "combine" with "sum" does get rid of the glitches for me.
Comment 9 farid 2017-03-05 19:30:06 UTC
S. Christian, could you please test and see if this is fixed with MLT > 6.4? Also close if so.

Thanks!
Comment 10 S. Christian Collins 2017-03-09 15:38:06 UTC
I can repro this 100% using Kdenlive 16.12.2 with MLT 6.5.0 (appimage).
Comment 11 S. Christian Collins 2017-03-09 15:39:24 UTC
(In reply to S. Christian Collins from comment #10)
> I can repro this 100% using Kdenlive 16.12.2 with MLT 6.5.0 (appimage).

Just realized my comment might have been a bit unclear. I can reproduce the bug every time is what I should have said.
Comment 12 Abe 2017-08-06 18:05:00 UTC
The issue is still present on 17.04.3, and getting rid of "combine" still works as a solution.
Comment 13 Jean-Baptiste Mardelle 2017-08-09 07:42:16 UTC
I should have taken care of that sooner, sorry. I am thinking to change the audio mix for Kdenlive 17.08 so that we use "sum" instead of "combine" in the audio mix transition. Unfortunately I haven't had time to do more testing. For those of you who tried it, do you think we can safely replace the "combine" option with "sum" in existing projects ? Does it seem to change the audio levels or is it ok ?

Thanks for your feedback. Deadline is tomorrow to get the change in Kdenlive 17.08 so if you can give me some feedback, would be wonderful
Comment 14 Abe 2017-08-09 08:02:55 UTC
For me it's currently necessary to manually get rid of combine. Otherwise the produced video is not acceptable.

I haven't done a ton of audio mixing though. I will produce something with 4 audio tracks, and render it both ways, see if there are any issues and report back later today.
Comment 15 Abe 2017-08-09 09:22:47 UTC
Created attachment 107176 [details]
Test the difference between combine and sum, produce wav results

Two projects that combine 4 wav files (sine waves) using either "combine" or "sum". "combine" produces regular clicks audible with headphones. "sum" does not produce click, but the final volume is quieter, which probably needs to be compensated in kdenlive.
Comment 16 Abe 2017-08-09 10:09:50 UTC
The resulting volume with "sum" seems to be quieter.

If "sum" is used and people haven't previously noticed the clicking, they may be upset by the unexpected lower volume. On the other hand, I believe Kdenlive may not be  used professionally with this clicking.

I do not know what to suggest. A pity that the deadline is tomorrow.

Personally, if sum is not used for now, I will write a script to work around this issue. I'll render audio and video separately, audio to wav using "sum", then normalize the audio, encode it to aac, then replace the clicky audio track with the new one using ffmpeg.
Comment 17 Jean-Baptiste Mardelle 2017-08-09 10:20:10 UTC
Created attachment 107177 [details]
sum with recent mlt

Hi. Seems like you are using an old MLT version.
The "sum" feature in the audio mix transition was added in november 2016.
The result you posted with the "sum" version seems to use the default mix transition which halves the audio samples before mix. I attached the wav file created with your files using a recent MLT and the "sum" feature working. Can you check if the audio is better (regarding clicks an volume) ? It seems like the volume is better than your version. Thanks
Comment 18 Abe 2017-08-09 11:57:07 UTC
Nice! Your version has no clicks and the original volume is maintained. Sounds great.

I'm on ArchLinux, and I thought I always had the most recent packages. In case of MLT, it's 6.4.1. Do you compile your own melt?
Comment 19 Jean-Baptiste Mardelle 2017-08-09 12:21:28 UTC
Yes, I always compile mlt from git. You are right, the "sum" feature was added 4 days after the 6.4.1 release, so it is not available in a stable version.

I will ask MLT's maintainer if we can have a new release in the near future.

Thanks for your feedback, so tonight I will try to implement the switch to the "sum" feature for MLT versions > 6.4.1 in Kdenlive 17.08. I will also convert existing projects on opening so everyone will benefit from it as soon as a new MLT is released.
Comment 20 Abe 2017-08-09 12:45:26 UTC
Thank you too for improving FOSS <3
Comment 21 Jean-Baptiste Mardelle 2017-08-09 17:36:57 UTC
Git commit 16690444c2340c869dc0815e8aaff4f9897c4c94 by Jean-Baptiste Mardelle.
Committed on 09/08/2017 at 17:36.
Pushed by mardelle into branch 'Applications/17.08'.

Fix audio mix clicks when using recent MLT

M  +0    -1    src/definitions.h
M  +13   -0    src/doc/documentvalidator.cpp
M  +6    -2    src/doc/kdenlivedoc.cpp
M  +5    -1    src/renderer.cpp
M  +12   -1    src/timeline/transitionhandler.cpp
M  +1    -0    src/timeline/transitionhandler.h

https://commits.kde.org/kdenlive/16690444c2340c869dc0815e8aaff4f9897c4c94
Comment 22 riku.seppala 2017-08-13 09:20:52 UTC
(In reply to Jean-Baptiste Mardelle from comment #19)
> Yes, I always compile mlt from git. You are right, the "sum" feature was
> added 4 days after the 6.4.1 release, so it is not available in a stable
> version.
> 
> I will ask MLT's maintainer if we can have a new release in the near future.
> 
This. Sorry to jump here on old closed bug but, I think most distros package only release versions and asking them to package git snapshot would be tall order. So yes the Google philosophy "release often" sounds good to end users...
Comment 23 Vincent PINON 2017-08-16 20:48:29 UTC
*** Bug 382544 has been marked as a duplicate of this bug. ***
Comment 24 S. Christian Collins 2017-09-07 16:08:54 UTC
I am using Kdenlive 17.08.0 now with custom-compiled MLT from git, which Kdenlive reports as version 6.5.0. However, new projects still are created using "combine" rather than "sum", and exhibit the clicky audio.

After manually editing the .kdenlive file to replace "combine" with "sum", I can confirm that MLT's new "sum" feature no longer reduces the volume :)
Comment 25 S. Christian Collins 2017-09-08 15:25:40 UTC
Just tested with Kdenlive 17.08.1, and the problem still exists. I am re-opening the bug.
Comment 26 kalimerox 2017-09-14 15:25:30 UTC
I have the same with 48khz 24bit audio...
Comment 27 farid 2017-09-14 15:36:06 UTC
(In reply to kalimerox from comment #26)
> I have the same with 48khz 24bit audio...

which version of mlt are you using?
Comment 28 kalimerox 2017-09-14 22:14:51 UTC
(In reply to farid from comment #27)
> (In reply to kalimerox from comment #26)
> > I have the same with 48khz 24bit audio...
> 
> which version of mlt are you using?

I use mlt 6.4.1-8

is this the last version?
Comment 29 kalimerox 2017-09-14 22:51:37 UTC
(In reply to kalimerox from comment #28)
> (In reply to farid from comment #27)
> > (In reply to kalimerox from comment #26)
> > > I have the same with 48khz 24bit audio...
> > 
> > which version of mlt are you using?
> 
> I use mlt 6.4.1-8
> 
> is this the last version?


sorry, i was wrong, kdenlive itself reports version 6.5.0 (with kdenlive 17.08.1)


while the system installed mlt  calls itself mlt-git version (r4510.1505079930.9076b710-1)

running on manjaro (but same clicks on my other linux mint machine)

it might be because i created the project with an older kdenlive version? should i try to tweak the session file to get a clean audio rendering?
Comment 30 farid 2017-09-14 23:29:59 UTC
(In reply to kalimerox from comment #28)
> (In reply to farid from comment #27)
> > (In reply to kalimerox from comment #26)
> > > I have the same with 48khz 24bit audio...
> > 
> > which version of mlt are you using?
> 
> I use mlt 6.4.1-8
> 
> is this the last version?
(In reply to kalimerox from comment #29)
> (In reply to kalimerox from comment #28)
> > (In reply to farid from comment #27)
> > > (In reply to kalimerox from comment #26)
> > > > I have the same with 48khz 24bit audio...
> > > 
> > > which version of mlt are you using?
> > 
> > I use mlt 6.4.1-8
> > 
> > is this the last version?
> 
> 
> sorry, i was wrong, kdenlive itself reports version 6.5.0 (with kdenlive
> 17.08.1)
> 
> 
> while the system installed mlt  calls itself mlt-git version
> (r4510.1505079930.9076b710-1)
> 
> running on manjaro (but same clicks on my other linux mint machine)
> 
> it might be because i created the project with an older kdenlive version?
> should i try to tweak the session file to get a clean audio rendering?


6.4.1 is the latest release but the fix of this bug is only in the git version. Since I see you are using an arch based system try mlt-git from AURand see if it works. If not maybe we should consider reopening this bug report in MLT?
Comment 31 S. Christian Collins 2017-09-15 00:29:45 UTC
(In reply to farid from comment #30)
> 6.4.1 is the latest release but the fix of this bug is only in the git
> version. Since I see you are using an arch based system try mlt-git from
> AURand see if it works. If not maybe we should consider reopening this bug
> report in MLT?

I can confirm that the bug in MLT affecting the "sum" mixing method has been fixed in current git, so we should not re-open the bug in MLT.

MLT allows two audio mixing methods to be used: "combine" and "sum". Using "combine" (as Kdenlive has done for a while now) is what causes the clicking audio. Using "sum" avoids this issue, but until a fix was committed in MLT git, "sum" would result in incorrect audio levels.

The patch presented in comment 21 is supposed to make Kdenlive as of version 17.08.0 use "sum" rather than "combine" audio mixing for new projects if MLT 6.5.0 or later is detected.

The reason I re-opened this bug is because even with MLT git installed (which Kdenlive reports as MLT 6.5.0), new projects still default to "combine" audio mixing. See my comment 24.
Comment 32 kalimerox 2017-09-15 07:41:24 UTC
> 
> 6.4.1 is the latest release but the fix of this bug is only in the git
> version. Since I see you are using an arch based system try mlt-git from
> AURand see if it works. If not maybe we should consider reopening this bug
> report in MLT?


I m trying  the mlt-git but kdenlive crashes on anything i do with that version ;( 

I will try to clean up the kdenlive config in home and try again. 

As it seems to be this:

"
The reason I re-opened this bug is because even with MLT git installed (which Kdenlive reports as MLT 6.5.0), new projects still default to "combine" audio mixing. See my comment 24."


I was wondering as a non programmer: would it make sense to edit the .kdenlive file, changing all "combine" entrys to "Sum" or something like this? just a wild guess...
Comment 33 kalimerox 2017-09-15 08:39:34 UTC
(In reply to kalimerox from comment #32)
> > 
> > 6.4.1 is the latest release but the fix of this bug is only in the git
> > version. Since I see you are using an arch based system try mlt-git from
> > AURand see if it works. If not maybe we should consider reopening this bug
> > report in MLT?
> 
> 
> I m trying  the mlt-git but kdenlive crashes on anything i do with that
> version ;( 


sorry guys it s me again. i think the mlt-git on AUR is very old, could this be the problem? 
https://aur.archlinux.org/packages/mlt-git/

it puts last updated 2016.. not sure if this means the actual package update..
Comment 34 S. Christian Collins 2017-09-15 14:36:51 UTC
(In reply to kalimerox from comment #32)
> I was wondering as a non programmer: would it make sense to edit the
> .kdenlive file, changing all "combine" entrys to "Sum" or something like
> this? just a wild guess...

Yes, this is what I do. I create and save a new video project, then edit the .kdenlive file, replacing all instances of "combine" with "sum". This gets rid of the clicky audio for me.
Comment 35 kalimerox 2017-09-16 13:09:18 UTC
(In reply to S. Christian Collins from comment #34)
> (In reply to kalimerox from comment #32)
> > I was wondering as a non programmer: would it make sense to edit the
> > .kdenlive file, changing all "combine" entrys to "Sum" or something like
> > this? just a wild guess...
> 
> Yes, this is what I do. I create and save a new video project, then edit the
> .kdenlive file, replacing all instances of "combine" with "sum". This gets
> rid of the clicky audio for me.


thank you! I tried this with the older mlt, is still clicky.. and when i try to install mlt-git, kdenlive would crash immediately.. so i have no chance to recover my project or see if it would help ;(  i ll keep trying...
Comment 36 farid 2019-11-27 15:30:41 UTC
Can try the latest MLT git you test? A recent fix was submitted to fix this:

https://github.com/mltframework/mlt/commit/25f28d95d689f28a6bea6232ef7e8308c71b189a
Comment 37 S. Christian Collins 2020-01-26 16:27:08 UTC
For me, this issue has been resolved since Kdenlive started using the "sum" mixing method by default. It would be interesting to know if kalimerox still has any issues.
Comment 38 lethal.logan 2020-05-11 21:29:28 UTC
Created attachment 128375 [details]
Video of Kdenlive glitchy audio with empty timeline and a jpeg

I also hear clicks and pops, or static, or crackling sounds when playing back the timeline without even adding in any audio, as can be seen in the attached video.

Kdenlive 20.04.0
Windows 10 64-bit 1909
Comment 39 emohr 2020-05-12 17:31:27 UTC
I see/hear the issue. Add a black empty clip. Maybe it stopps crackling (no joke).

It seems not an Kdenlive issue. Check if a cable connection is loose.
Follow this steps: https://www.howtogeek.com/285429/how-to-fix-crackling-or-popping-sound-on-a-windows-pc/. 

Similar here: https://blog.pcrisk.com/windows/12783-laptop-speakers-crackling-how-to-fix-it. 

I assume it's either a loose cable connection or some hardware accelerations set. If you have wireless boxes or headphones try to reconnect.
Comment 40 lethal.logan 2020-05-13 01:34:41 UTC
Thanks for the response emohr.

Changing any of those suggested sound device settings in windows does not resolve the issue. I also made a 1920x1080 png of just black and added that to the timeline. Still same issue, but I don't see why that would be any different anyway, because really we are talking about an empty timeline having the issue. As in, shouldn't it be a pure zero null audio output? Shouldn't the first question we be asking is why there is any audio output at all from Kdenlive?

I want to make it clear that there are no issues with audio or video playback on this computer. It plays video games, Youtube videos and music through Foobar2000 flawlessly. I have tried various other video editors and Kdenlive is the only one that has this issue.
Comment 41 farid 2020-05-19 21:15:20 UTC
MLT received a recent patch to fix the crackling maybe you could test once it is in the daily build:

https://github.com/mltframework/mlt/commit/bd3fa58ceeae20c3c9cddfc572fbf86c0a5d9793
Comment 42 emohr 2020-09-12 18:27:21 UTC
Please try with the current Kdenlive AppImage version 20.08.1 to see if it's fixed.
Comment 43 Bug Janitor Service 2020-09-27 04:33:10 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 44 Abe 2020-09-27 09:48:07 UTC
I just tried to load the provided audio file for testing, added it to two tracks slightly offset (but overlapping) in time, previewed, exported, and did not hear any clicks, just pure sine wave. 

With Kdenlive 20.08.1 under Arch Linux. 

For me it seems to be resolved.
Comment 45 Abe 2020-09-27 09:50:05 UTC
Forgot to include melt version 6.22.1
Comment 46 Bug Janitor Service 2020-10-12 04:33:11 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 47 S. Christian Collins 2020-10-13 15:42:28 UTC
As I mentioned in comment #37, this bug has been fixed ever since kdenlive started using the "sum" audio mixing method instead of "combine". I am marking the bug as fixed.