Bug 432915 - Kdenlive + OBS audio corruption bug [2021]
Summary: Kdenlive + OBS audio corruption bug [2021]
Status: CONFIRMED
Alias: None
Product: kdenlive
Classification: Applications
Component: Video Display & Export (show other bugs)
Version: 20.12.0
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-14 06:48 UTC by katastic
Modified: 2021-03-07 05:59 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:
fritzibaby: timeline_corruption+
j77xa3sl: timeline_corruption+


Attachments
Kdenlive + OBS audio preview corruption bug.png (102.19 KB, image/png)
2021-02-27 12:56 UTC, emohr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description katastic 2021-02-14 06:48:29 UTC
https://www.youtube.com/watch?v=joUC23LASPk

Kdenlive bug:

0:00​ Selecting certain areas of video, the video freezes for awhile and then the audio plays stuttered at like 8x speed. 

0:24​ Meanwhile, selecting other areas magically works. 

0:44​ Another broken section

OBS, CQP encoding (CQ 23) using NVENC H.264 (new). OBS is brand new (v26.1.1 at the time of recording)

The bug happens EVERY TIME at the SAME locations of the video file. ala the same section of video will always fail to preview.

 - File is ~5 GB. Has 3 audio tracks and 1 video track at 30 FPS.

 - The only thing I could even imagine (other than a straight up bug) is the OBS encoder was occasionally missing frames (less than 30 FPS) and Kdenlive explodes when it hits a chunk that has less than the designated "file wide" assumed expected FPS.

 - File plays JUST FINE in Media Player Classic and VLC
Comment 1 katastic 2021-02-14 07:08:00 UTC
 - It appears to be FINE when RENDERED, only the PREVIEW is affected.
Comment 2 katastic 2021-02-14 14:06:31 UTC
Another poster with the same issue.

https://forum.kde.org/viewtopic.php?f=265&t=169978&p=442879#p442879

> playback is out of sync with audio and playback is like speedup twice or three time
Comment 3 j77xa3sl 2021-02-14 20:40:03 UTC
Identical to issue reported here:
https://forum.kde.org/viewtopic.php?t=169978
Comment 4 emohr 2021-02-15 18:52:05 UTC
I assume the NVENC H.264 file is the issue. Can you export out of OBS with another codec? How many audio channels do you use? Can you try without the MKV container?
Comment 5 j77xa3sl 2021-02-17 22:20:36 UTC
@emohr I have an x264 encoded video file. Same issue.
Comment 6 j77xa3sl 2021-02-27 12:28:18 UTC
Issue still present in Nightly build 21.03.70
Comment 7 emohr 2021-02-27 12:56:50 UTC
Created attachment 136219 [details]
Kdenlive + OBS audio preview corruption bug.png

I see on the YouTube video that the clip job for preview is still running (in the project bin) while you playback. Let the job finishing before you playback. Still the same issue.
Comment 8 katastic 2021-03-06 05:27:52 UTC
This also affected a bluray rip of the movie Hot Rod.

I let the preview rendering run and it still did it.

Not OBS. Not NVENC.
Comment 9 emohr 2021-03-06 08:48:10 UTC
Could you upload a short portion (ca. 1.5min) of the video that I can check if this preview stutter happens on Windows as well? Do you are on Linux?
Comment 10 katastic 2021-03-07 02:37:30 UTC
I THINK I FOUND THE ISSUE, as well as a WORKAROUND for users:

 - It affects MKV files of significant length. Chopping Hot Rod down to a 1 minute clip (of the affected region) removed the issue. But more importantly:

 - Converting the files to MP4 format __removes the issue__ 

    ffmpeg -i [myfile] -c copy -map 0 [output.mp4]

    [the -map 0 switch is for keeping multiple audio tracks]

 - Tested on both the Hot Rod movie bluray as well one of my affected OBS recordings 

So as far as I can tell, using MP4 files prevents the bug from occurring.





Here is the ffprobe output of the BREAKING version of the Hot Rod movie:
-----------------------------------------------------------------------------
ffmpeg version N-100410-gcd821c18dc Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3-win32 (GCC) 20200320
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --enable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
  libavutil      56. 62.100 / 56. 62.100
  libavcodec     58.115.102 / 58.115.102
  libavformat    58. 65.100 / 58. 65.100
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 93.100 /  7. 93.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, matroska,webm, from 'Hot.Rod.2007.1080p.BluRay.DTS.x264-ETRG.mkv':
  Metadata:
    encoder         : libebml v1.3.3 + libmatroska v1.4.4
    creation_time   : 2016-06-29T19:51:54.000000Z
  Duration: 01:27:56.15, start: 0.000000, bitrate: 7371 kb/s
    Chapter #0:0: start 0.000000, end 512.845000
    Metadata:
      title           : Chapter  1
    Chapter #0:1: start 512.845000, end 938.062000
    Metadata:
      title           : Chapter  2
    Chapter #0:2: start 938.062000, end 1444.276000
    Metadata:
      title           : Chapter  3
    Chapter #0:3: start 1444.276000, end 2003.042000
    Metadata:
      title           : Chapter  4
    Chapter #0:4: start 2003.042000, end 2456.745000
    Metadata:
      title           : Chapter  5
    Chapter #0:5: start 2456.745000, end 2971.843000
    Metadata:
      title           : Chapter  6
    Chapter #0:6: start 2971.843000, end 3441.396000
    Metadata:
      title           : Chapter  7
    Chapter #0:7: start 3441.396000, end 3952.782000
    Metadata:
      title           : Chapter  8
    Chapter #0:8: start 3952.782000, end 4438.809000
    Metadata:
      title           : Chapter  9
    Chapter #0:9: start 4438.809000, end 4982.894000
    Metadata:
      title           : Chapter 10
    Chapter #0:10: start 4982.894000, end 5276.150000
    Metadata:
      title           : Chapter 11
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x832 [SAR 1:1 DAR 30:13], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      BPS             : 5860624
      BPS-eng         : 5860624
      DURATION        : 01:27:56.146000000
      DURATION-eng    : 01:27:56.146000000
      NUMBER_OF_FRAMES: 126501
      NUMBER_OF_FRAMES-eng: 126501
      NUMBER_OF_BYTES : 3865188624
      NUMBER_OF_BYTES-eng: 3865188624
      _STATISTICS_WRITING_APP: mkvmerge v9.2.0 ('Photograph') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.2.0 ('Photograph') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-06-29 19:51:54
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-06-29 19:51:54
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
    Metadata:
      title           : Surround Sound
      BPS             : 1508999
      BPS-eng         : 1508999
      DURATION        : 01:27:56.150000000
      DURATION-eng    : 01:27:56.150000000
      NUMBER_OF_FRAMES: 494639
      NUMBER_OF_FRAMES-eng: 494639
      NUMBER_OF_BYTES : 995213668
      NUMBER_OF_BYTES-eng: 995213668
      _STATISTICS_WRITING_APP: mkvmerge v9.2.0 ('Photograph') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.2.0 ('Photograph') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-06-29 19:51:54
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-06-29 19:51:54
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES



I simply converted using ffmpeg with "-c copy" to MP4 and now the output:
-----------------------------------------------------------------------------
ffprobe version N-100410-gcd821c18dc Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9.3-win32 (GCC) 20200320
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --enable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
  libavutil      56. 62.100 / 56. 62.100
  libavcodec     58.115.102 / 58.115.102
  libavformat    58. 65.100 / 58. 65.100
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 93.100 /  7. 93.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output2-full.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.65.100
  Duration: 01:27:56.15, start: 0.000000, bitrate: 7380 kb/s
    Chapter #0:0: start 0.000000, end 512.845000
    Metadata:
      title           : Chapter  1
    Chapter #0:1: start 512.845000, end 938.062000
    Metadata:
      title           : Chapter  2
    Chapter #0:2: start 938.062000, end 1444.276000
    Metadata:
      title           : Chapter  3
    Chapter #0:3: start 1444.276000, end 2003.042000
    Metadata:
      title           : Chapter  4
    Chapter #0:4: start 2003.042000, end 2456.745000
    Metadata:
      title           : Chapter  5
    Chapter #0:5: start 2456.745000, end 2971.843000
    Metadata:
      title           : Chapter  6
    Chapter #0:6: start 2971.843000, end 3441.396000
    Metadata:
      title           : Chapter  7
    Chapter #0:7: start 3441.396000, end 3952.782000
    Metadata:
      title           : Chapter  8
    Chapter #0:8: start 3952.782000, end 4438.809000
    Metadata:
      title           : Chapter  9
    Chapter #0:9: start 4438.809000, end 4982.894000
    Metadata:
      title           : Chapter 10
    Chapter #0:10: start 4982.894000, end 5276.150000
    Metadata:
      title           : Chapter 11
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x832 [SAR 1:1 DAR 30:13], 5860 kb/s, 23.98 fps, 23.98 tbr, 16k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
    Stream #0:1(eng): Audio: dts (DTS) (mp4a / 0x6134706D), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
    Stream #0:2(eng): Data: bin_data (text / 0x74786574)
    Metadata:
      handler_name    : SubtitleHandler
Unsupported codec with id 100359 for input stream 2



I cannot exhaustively say it doesn't break. But I keep flipping through it and nothing is breaking so far.




Output for my OBS recordings:
-----------------------------------------------------------------------------

Original MKV file ffprobe

 libavutil      56. 62.100 / 56. 62.100
  libavcodec     58.115.102 / 58.115.102
  libavformat    58. 65.100 / 58. 65.100
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 93.100 /  7. 93.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, matroska,webm, from '2021-03-04 18-51-20.mkv':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 01:38:47.63, start: 0.000000, bitrate: 5170 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
    Metadata:
      DURATION        : 01:38:47.633000000
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Track1
      DURATION        : 01:38:47.552000000
    Stream #0:2: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Track2
      DURATION        : 01:38:47.552000000
    Stream #0:3: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Track3
      DURATION        : 01:38:47.552000000


New version using -c copy -map 0  to mp4    [NOTE: -map 0 is required for multiple audio tracks to move over]
-----------------------------------------------------------------------------
  libavutil      56. 62.100 / 56. 62.100
  libavcodec     58.115.102 / 58.115.102
  libavformat    58. 65.100 / 58. 65.100
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 93.100 /  7. 93.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2021-03-04 18-51-20B.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.65.100
  Duration: 01:38:47.63, start: 0.000000, bitrate: 5174 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 4681 kb/s, 30 fps, 30 tbr, 16k tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 161 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
    Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
    Stream #0:3(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 157 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Comment 11 katastic 2021-03-07 02:40:32 UTC
 - For those that don't know, converting to MP4 from MKV does not change or re-encode the data so it will not make it "lossy" or recompressed. The only trick there is remembering -map 0 for multi-track recordings or it will only copy the first audio track.

 - It's also possible for OBS users that the OBS "remux" command [File -> Remux Recordings] will do this same conversion without requiring you to install ffmpeg or understand how to use command prompt.
Comment 12 katastic 2021-03-07 05:59:57 UTC
Oh, I missed a previous comment. This affects WINDOWS.