mlt icon indicating copy to clipboard operation
mlt copied to clipboard

Crackling sound when cutting pcm_s24le in mkv

Open aruseni opened this issue 3 months ago • 2 comments

I was editing a video in Kdenlive and noticed an annoying crackling sound after one of the cuts.

The video was h264 / pcm_s24le in an mkv.

For my video, I was able to solve the issue by just converting the audio to flac.

Here is a related bug: #1014.

Steps to reproduce the behavior

First, create an mkv with pcm_s24le sound

melt -profile atsc_1080p_24 tone: out=240 frequency=440 level=-5 -consumer avformat:sine440hz.mkv vcodec=libx264 acodec=pcm_s24le

Then try to cut this video:

melt sine440hz.mkv in=10 -consumer avformat:test.wav

Expected behavior

The sound is a clear 440 Hz sine wave.

Actual result

There is crackling sound at the beginning.

Waveform

Additional context

If you use a wav file instead, melt does not have any issues cutting the audio.

aruseni avatar Sep 18 '25 19:09 aruseni

Thanks for your detailed report. The steps were easy to follow because you provided command line examples. Unfortunately, when I follow your instructions, I do not find any crackling artifacts in the output file. Maybe it has something to do with the verions we are using.

I am using:

bmatherly avatar Nov 07 '25 03:11 bmatherly

Hey Brian,

Thanks a lot for looking into this! I’m happy to provide any further details you might need.

It would also be great if someone else could try to reproduce this on their machine to check if this works as expected.

Here are the version details:

$ melt --version
melt 7.34.1
Copyright (C) 2002-2025 Meltytech, LLC
<https://www.mltframework.org/>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ffmpeg -version
ffmpeg version n8.0.1 Copyright (c) 2000-2025 the FFmpeg developers
built with gcc 15.2.1 (GCC) 20251112
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libdvdnav --enable-libdvdread --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
libavutil      60.  8.100 / 60.  8.100
libavcodec     62. 11.100 / 62. 11.100
libavformat    62.  3.100 / 62.  3.100
libavdevice    62.  1.100 / 62.  1.100
libavfilter    11.  4.100 / 11.  4.100
libswscale      9.  1.100 /  9.  1.100
libswresample   6.  1.100 /  6.  1.100

Exiting with exit code 0

I am still able to reproduce the issue. Below are the commands I used and their exact output.

Note: I noticed that melt exits with a segmentation fault. However, the command still completes its task and generates the file before crashing.

1. Creating the initial test file (MKV) with a sine wave:

$ melt -profile atsc_1080p_24 tone: out=240 frequency=440 level=-5 -consumer avformat:sine440hz.mkv vcodec=libx264 acodec=pcm_s24le
mlt_repository_init: failed to dlopen /usr/lib/mlt-7/libmltrtaudio.so
  (librtaudio.so.7: cannot open shared object file: No such file or directory)
mlt_repository_init: failed to dlopen /usr/lib/mlt-7/libmltmovit.so
  (libmovit.so.8: cannot open shared object file: No such file or directory)
mlt_repository_init: failed to dlopen /usr/lib/mlt-7/libmltsox.so
  (libsox_ng.so.3: cannot open shared object file: No such file or directory)
+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
|1=-10| |2= -5| |3= -2| |4= -1| |5=  0| |6=  1| |7=  2| |8=  5| |9= 10|
+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
+---------------------------------------------------------------------+
|               H = back 1 minute,  L = forward 1 minute              |
|                 h = previous frame,  l = next frame                 |
|           g = start of clip, j = next clip, k = previous clip       |
|                0 = restart, q = quit, space = play                  |
+---------------------------------------------------------------------+
[matroska @ 0x7fd5b8200fc0] Timestamps are unset in a packet for stream 1. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[matroska @ 0x7fd5b8200fc0] Encoder did not produce proper pts, making some up.
Current Position:        240
Segmentation fault         (core dumped) melt -profile atsc_1080p_24 tone: out=240 frequency=440 level=-5 -consumer avformat:sine440hz.mkv vcodec=libx264 acodec=pcm_s24le

2. Cutting the MKV file:

$ melt sine440hz.mkv in=10 -consumer avformat:test.wav
mlt_repository_init: failed to dlopen /usr/lib/mlt-7/libmltrtaudio.so
  (librtaudio.so.7: cannot open shared object file: No such file or directory)
mlt_repository_init: failed to dlopen /usr/lib/mlt-7/libmltmovit.so
  (libmovit.so.8: cannot open shared object file: No such file or directory)
mlt_repository_init: failed to dlopen /usr/lib/mlt-7/libmltsox.so
  (libsox_ng.so.3: cannot open shared object file: No such file or directory)
+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
|1=-10| |2= -5| |3= -2| |4= -1| |5=  0| |6=  1| |7=  2| |8=  5| |9= 10|
+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
+---------------------------------------------------------------------+
|               H = back 1 minute,  L = forward 1 minute              |
|                 h = previous frame,  l = next frame                 |
|           g = start of clip, j = next clip, k = previous clip       |
|                0 = restart, q = quit, space = play                  |
+---------------------------------------------------------------------+
[wav @ 0x7f7cc8001000] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[wav @ 0x7f7cc8001000] Encoder did not produce proper pts, making some up.
Current Position:        230
Segmentation fault         (core dumped) melt sine440hz.mkv in=10 -consumer avformat:test.wav

When I open the resulting test.wav with Audacity and zoom in, an artifact is visible right before the 0.05 mark:

Image

The problem seems specific to MKV files. If I convert the MKV to a WAV first, and then perform the cut, the output is clean.

1. Converting to WAV:

$ ffmpeg -i sine440hz.mkv sine440hz.wav
ffmpeg version n8.0.1 Copyright (c) 2000-2025 the FFmpeg developers
  built with gcc 15.2.1 (GCC) 20251112
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libdvdnav --enable-libdvdread --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
  libavutil      60.  8.100 / 60.  8.100
  libavcodec     62. 11.100 / 62. 11.100
  libavformat    62.  3.100 / 62.  3.100
  libavdevice    62.  1.100 / 62.  1.100
  libavfilter    11.  4.100 / 11.  4.100
  libswscale      9.  1.100 /  9.  1.100
  libswresample   6.  1.100 /  6.  1.100
[aist#0:1/pcm_s24le @ 0x556ec6b4bd80] Guessed Channel Layout: stereo
Input #0, matroska,webm, from 'sine440hz.mkv':
  Metadata:
    ENCODER         : Lavf62.3.100
  Duration: 00:00:10.04, start: 0.000000, bitrate: 2325 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 1k tbn
    Metadata:
      DURATION        : 00:00:10.042000000
  Stream #0:1: Audio: pcm_s24le, 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
    Metadata:
      DURATION        : 00:00:10.042000000
Stream mapping:
  Stream #0:1 -> #0:0 (pcm_s24le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'sine440hz.wav':
  Metadata:
    ISFT            : Lavf62.3.100
  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      encoder         : Lavc62.11.100 pcm_s16le
      DURATION        : 00:00:10.042000000
[out#0/wav @ 0x556ec6b4ff00] video:0KiB audio:1883KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.004046%
size=    1883KiB time=00:00:10.04 bitrate=1536.1kbits/s speed=3e+03x elapsed=0:00:00.00

2. Cutting the WAV file:

$ melt sine440hz.wav in=10 -consumer avformat:test.wav
mlt_repository_init: failed to dlopen /usr/lib/mlt-7/libmltrtaudio.so
  (librtaudio.so.7: cannot open shared object file: No such file or directory)
mlt_repository_init: failed to dlopen /usr/lib/mlt-7/libmltmovit.so
  (libmovit.so.8: cannot open shared object file: No such file or directory)
mlt_repository_init: failed to dlopen /usr/lib/mlt-7/libmltsox.so
  (libsox_ng.so.3: cannot open shared object file: No such file or directory)
+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
|1=-10| |2= -5| |3= -2| |4= -1| |5=  0| |6=  1| |7=  2| |8=  5| |9= 10|
+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
+---------------------------------------------------------------------+
|               H = back 1 minute,  L = forward 1 minute              |
|                 h = previous frame,  l = next frame                 |
|           g = start of clip, j = next clip, k = previous clip       |
|                0 = restart, q = quit, space = play                  |
+---------------------------------------------------------------------+
[wav @ 0x7f3344200fc0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[wav @ 0x7f3344200fc0] Encoder did not produce proper pts, making some up.
Current Position:        240
Segmentation fault         (core dumped) melt sine440hz.wav in=10 -consumer avformat:test.wav

If we open test.wav in Audacity and zoom in, we see a clear sine wave, no artifacts.

Image

Please let me know if you need any more tests from my end.

Have a great weekend! ✨

aruseni avatar Dec 06 '25 17:12 aruseni