Reply to topic

Audio Pops in Renders - Bug Report and Workaround

mentil
Registered Member
Posts
2
Karma
0
TL;DR: Jump to the end for the workaround.

I found a few other threads of people mentioning problems with pops in audio, however they had little info, were old (for the most part), and most importantly, had no solution. I have enough details to hopefully track down this problem and stamp it out. My basic problem is that my rendered output had many pops in it (I counted 26 separate conspicuous instances, in a 9 minute video), even though the preview video didn't have these pops (and of course, the source audio did not, I checked that first.) Each of those 'instances' was actually usually a cluster of pops all happening in a brief period of time in one clip.

I'm running KDEnlive 17.12.0 on Windows 10 64-bit, MLT 6.5.0, FFmpeg 3.4.1 win64, 12GB of RAM (not close to full usage). I have one video file cut into 141 clips, 11 dialog files cut into ~160 clips, and a dozen background music files/clips. All of the dialog files are in uncompressed WAV format, music was MP3. I rendered to a h265/MP4 file and noticed lots of pops in the dialog; rebooted my computer and rendered again, the pops were in the exact same spots as before. I shouldn't say that there were NO pops in the preview video... but the pops there are inconsistent; I can replay over the same spot and the pops will be gone or move, disappearing after jogging over the same spot a few times. I then rendered to a WAV file, and the pops were at the exact same spot as they were in the video file; so with a WAV source and WAV render target, I know the problem isn't in decompression or compression (I had disabled the MP3 music track by this point). In fact, rendering to a WAV file dozens of times, the pops were always in the exact same spots and sounded exactly the same, meaning it's reproducible/consistent.

I loaded up the rendered WAV file in Audacity, expecting the pops to register as clipped spikes of 100% amplitude. I found zero such spikes. Instead, I found areas that were corrupted in two different ways, which I believe to be two separate bugs. The first problem is easier to explain, but didn't seem to cause a pop: sections of an audio clip at very low amplitude would be rounded to 0, giving a completely flat line in Audacity (rather than a shallow wave) with no ability to amplify it. This is with no Gain or other effects active on the clip, and no overlapping audio.

The second problem is stranger. I synced up (in Audacity) a line of dialog from the source, with the same line in the rendered output, in another track, synced to within 1 audio sample. At this point someone's going to ask what sample rate I used. Some of the dialog files were 48khz and others were 44.1khz, some mono and some stereo, but pops appeared in each when rendered regardless of source sample rate or number of channels. I rendered to 48khz WAV files for the most part, although a test render to 44.1khz (I made a custom render profile based on the WAV profile, and yes I confirmed the output file was actually 44.1khz; parameters: properties=WAV frequency=44100) gave pops at the exact same locations. In this case, the source audio for this line was 44.1khz stereo, 32bit float. I hunted down the pops in the audio; in a 1.528 second clip I found 5 anomalies, one of which was caused by the above problem, the other 4 caused by this one. Here's the weird thing: only 2 of the anomalies resulted in conspicuously audible pops, so there are likely double the number of instances of this bug as one would notice just from listening. However, 2 pops within 1.5 seconds means one audible pop every 0.75 seconds, which is quite distracting; and that's just on average, they tend to be clustered which is even more distracting.

Scrolling through the synced audio clips, I noticed that they became desynchronized at points where this 2nd bug manifests. They didn't gradually desynchronize at a regular rate, they remained in 1:1 synchronization (not just approximately, but to the sample) except for where an anomaly occurred. These anomalies led to a number of samples being deleted from the clip, often causing an audible pop. The effect can be easily simulated by highlighting a handful of samples, and pressing the delete key. If a clip contains several of these deletions, it can cause the clip to be mildly truncated/desynchronized, which is likely to be a problem for long audio clips; this has probably been responsible for 'audio desync' problems for years and noone knew why, assuming it had to do with sample rate conversion. In this 1.528 second long clip, the deletions were: ~61, ~36, 17, and 160 samples for each of the 4 deletions respectively (the last 2 I counted precisely). The 2nd and 4th deletions were audible as pops; the magnitude of amplitude change at the boundaries of the deletion seems to be the determining factor in audibility. So, looking at the audio waveform, these deletions look like a sudden sharp cliff rather than a smooth wave.
Edit: I forgot to mention that on either side of the deletions, around 3 samples would have their amplitude slightly modified; so the problem isn't ONLY that some samples were deleted, a few are modified as well.

So, about 274 samples were deleted from a ~67k sample clip, causing about 0.4% shorter audio than it should be, which would be about 15 seconds short on a 1 hour long audio clip. However, I mostly noticed the popping near the beginning of audio clips; I didn't scour any long clips for deletions, so can't be sure a single long clip would have them at the same rate. One thing I did notice is that 3 of the deletions happened in the first 0.5 seconds (1/3rd) of the clip, with the 4th occurring exactly 1.0013 seconds after the 2nd. There seems to be a connection between these two deletions, and given that they were the ones audible as pops, it seems a good target for fixing. In fact, I very frequently noticed two pops happening perhaps a second apart.

I did another render and resynced it to source audio, and the deletions were at the exact same spots as the prior render, to the sample. That even happened when I rendered to a 44.1khz WAV, although something interesting happened in that case: the 17 sample deletion turned into a 34 sample deletion.

I made a few screenshots of Audacity highlighting both of the bugs, and will find somewhere to upload them later.
Edit: First bug highlighted here: http://i1160.photobucket.com/albums/q497/mentil09/problem%20rounding_zpsoqqnjgjf.png
Second bug highlighted in these two instances: http://i1160.photobucket.com/albums/q497/mentil09/problem%2061%20samples_zpso9ez0m9r.png
http://i1160.photobucket.com/albums/q497/mentil09/problem%2017%20samples_zpss1jqiojh.png
In these screenshots, the samples that were deleted/modified are selected in the source audio file on bottom; the final rendered audio is on top.

After much experimenting, and finding lots of things that don't work, I eventually stumbled upon some workarounds.
What didn't work: Deleting all Effects prior to the clip that was popping. Moving a clip a few frames/seconds forward or backward. Swapping a clip's location with an adjacent clip on the same track. Deleting adjacent clips. Putting an audio clip in the middle of a video clip as opposed to its beginning or ending. Moving the clip then moving it back.

What worked: Moving an audio clip to another track at the same point on the timeline USUALLY fixed the pop. All the dialog was originally in one track (except in cases of overlapping dialog); moving the clips which popped into another track cut it down from 26 popping clips, to 9. Most of those 9 clips were part of the 26, however one or two of those were clips adjacent to the ones I had moved, so make sure to double check adjacent lines. The popping sounded less severe in those 9 clips. I moved those 9 clips to a third track, which brought it down to 2 popping clips. Moving those 2 into a new fourth track left 1 popping clip, which I couldn't move around in order to fix. Incidentally, reenabling the background music track eliminated the popping in that final troublesome clip. The BGM had some minor popping in it but I couldn't think of a way to fix that. Clips seem to be more likely to have popping if they're crowded close together, with little gap inbetween them. That one clip I couldn't fix by moving it around? It overlapped another dialog clip in another track.
Also, moving a clip that was near the end, to the beginning of the same track, got rid of its pops... although that's probably not where you'll want it, and it doesn't help if you just have one audio clip that starts at the beginning already.

Hopefully a developer will see this and fix the issue(s), unsure if they trawl this forum or where else to post it. I've spent hours messing with this problem (and typing up this post) and can do more tests if necessary.
maartenb
Registered Member
Posts
10
Karma
0
Hi Mentil,

Good that you found a workaround! For me it did not work.

I have a suspicion that the ticks in my project appear in audio clips that are recorded in 24 bits. These clips are mixed with a background audio track of 16 bits.

More investigation is needed.


Maarten

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], bartoloni, Bing [Bot], blogthetech, boudewijn, Google [Bot], gui-m, ipwizard, ramskulls, skylerjett, Sogou [Bot], YaCy [Bot]