This forum has been archived. All content is frozen. Please use KDE Discuss instead.

On rendering, audio/video get progressively out of sync

Tags: None
(comma "," separated)
User avatar
balleyne
Registered Member
Posts
1
Karma
0
I'm having some major audio/video sync issues on rendering, and I can't figure out what's going on or why.

I recorded audio separately from video for this project. I put both into Kdenlive, and lined them up using a clap towards the beginning. When I play the video from within Kdenlive, it's lined up pretty well and looks fine. The whole edited video is 20 minutes long

The problem is that when I render it - whether to MP4 or WebM - it starts out fine towards the beginning, but by the 20 minute mark the audio is so far ahead of the video that it's incredibly noticeable. It's around the 13-15min mark that I started to notice it, and by the end it was painful. (I've noticed this issue with other projects I've done in Kdenlive too, but I've never rendered a video file this long - now it's become obvious to me there's a problem at the rendering stage, not just in editing or in my perception or something.)

Here's the rendered video:
https://media.blaise.ca/tob/kdenlive.mp4

My inputs/environment:
  • Debian 10 with Kdenlive 18.12.3
  • 720p MP4 video from my camcorder, and I disregard the audio from this
  • WAV file that I exported from Ardour with audio I recorded from a separate source, that I've lined up in Kdenlive

I've tried a whole bunch of different things, with mixed results, but I can't see to figure out what the problem is:
  • I've reviewed these forums posts which describe similar issues, but no clear solution
  • I've tried rendering to MP4 and to WebM, same result
  • I've tried rendering just the audio to WAV, and then using ffmpeg to drop the audio from the MP4 file and then ffmpeg to combine the video-only rendered MP4 with the rendered WAV - same result
  • I tried downloading the latest Kdenlive 20.04.0 Appimage, but I get the same result.
  • I've tried rendered 5min zones at a time, but I get the same result - that is, the 15-20min zone is rendered with the same lag as if it were rendered all 20min at once
  • Notably, when I play the rendered video using MLT (melt from the command line), it does not have the problem and it plays like it did in Kdenlive. Like, the audio/video sync isn't perfect - which may be my own error in lining it up - but it's consistent - it doesn't drift from the start of the video to the end like it does when I open it up in mplayer or Totem or play in Firefox

The key thing is that you can take that same MP4 file, play it in mplayer or totem (or it was particular bad in VLC on Android...) and compared that with MLT... there's a noticeable difference, especially in the last 5 minutes. Like, take a look at my final remarks in the last minute of the video. Night and day comparison, or whether it could be passable or whether it's clearly out of sync to any viewer.

Code: Select all
balleyne@exponentia:~/catholic/tob/2020-05-04_TOB-virtual-conference$ ffprobe final.mp4
ffprobe version 4.1.4-1~deb10u1 Copyright (c) 2007-2019 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'final.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:20:00.43, start: 0.000000, bitrate: 1898 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/unknown/bt709), 1280x720 [SAR 1:1 DAR 16:9], 1729 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
    Metadata:
      handler_name    : SoundHandler


Now, if I ffprobe the audio only export, I get this:
Code: Select all
balleyne@exponentia:~/catholic/tob/2020-05-04_TOB-virtual-conference$ ffprobe audio.wav
ffprobe version 4.1.4-1~deb10u1 Copyright (c) 2007-2019 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, wav, from 'audio.wav':
  Metadata:
    copyright       : CC BY-SA
    title           : The Theology of the Body and Music (Blaise Alleyne)
    encoder         : Lavf58.20.100
  Duration: 00:20:00.00, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s


Notice that the duration on the WAV file export is 00:20:00.00... whereas the duration on the MP4 export is 00:20:00.43... when I play in mplayer, towards the end of the video if I manually adjust the a/v sync to -300ms it starts looking natural again... Could there be an issue with the length of the audio versus the length of the video, and something with the container formats and how it's played together?

Just a wild guess, but I can't figure out what's wrong or how to fix it... Any help would be greatly appreciated, because it's supremely frustrating to have pulled two all nighters to put together a project, and have it fall apart at the rendering stage after spending hours and hours in Kdenlive to edit!

Last edited by balleyne on Tue May 12, 2020 6:15 am, edited 1 time in total.
keithfrank
Registered Member
Posts
1
Karma
0
I am having the exact same issue.
User avatar
bartoloni
Moderator
Posts
1510
Karma
4
OS
MusicWeRemember
Registered Member
Posts
1
Karma
0
I watched your clip, and it seems to jump wildly out of sync after the final edit from the song to you talking. Interestingly, this is nearly identical to my problem, where, right around the 19 minute mark, and following an edit, the audio and video are suddenly way out of sync. Everything looks fine when played back within Kdenlive.

Using Mint 19.3 Cinnamon and Kdenlive v20.04.1 running from an appimage.
I also just tried rendering in the latest Kdenlive appimage : v20.07.70 with identical results.
Same with an install of Kdenlive v17.12.3

Even when I render only the segment in question, the issue is still there : https://youtu.be/TLTzzJH7ReE As OP mentioned was the case when rendering his project in segments.
So it doesn't seem to be related to actual length of the rendered clip, but position in the timeline?

As a cheat, I went and clipped out a segment of video following the edit, and moved the rest of the video segments back to cover the gap. Upon exporting, everything is finally looking in sync (better than before). But if I drop the originally rendered mp4 back into Kdenlive, it plays back just fine, without the sync issue. Interested to hear what kind of solutions are available. I just started using v20.04.1 on a new system, but previously had no such issues on my previous one (which was about 12 years old). At least render time for a ~30m clip is now around 30 minutes long instead of 4.5 hours. I'll try experimenting with some similar, non-critical video/audio content to see if this is a consistent issue that just "happens" around 19 minutes with or without edits. Very frustrating!



My ffprobe output on the mp4 video :

Code: Select all
ffprobe Session\ 10fixed.mp4
ffprobe version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2007-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Session 10fixed.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:36:44.44, start: 0.000000, bitrate: 10468 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/unknown/bt709), 1920x1080 [SAR 1:1 DAR 16:9], 10210 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 249 kb/s (default)
    Metadata:
      handler_name    : SoundHandler


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]