Stuttering preview and all memory taken while rendering after update [solved]

Hey Folks!

I'm using Kdenlive for about half a year now, haven't had major problems at all. A few days ago I updated my Gentoo-system to ~x86, which is the "unstable" branch of portage. From all I heard and looking at the other programs running fine, this "unstable" branch isn't very unstable.

With this update, Kdenlive was updated from 0.9.2. to 0.9.4 and mlt from 0.8.2 to 0.8.8. Now, when I try editing a video, the audio is out of sync with the video and stutters. A lot. I have a video-track without audio, an audio-track containing the videos audio and a second audio track. The project was generated with the old version of Kdenlive and all was fine. When I opened the project in the new version, the audio is out of sync, I think. Can't really tell, because of the stuttering, but I think it's a bit of. Also, when I try to render a part of the project, after about 2 minutes, my 8 GB Ram is full. That didn't happen before. I tested this with a part of the project I could successfully render before.

After playing around with audio-/video-drivers and opengl (and disabling pulseaudio via pasuspender), I gave up and decided to downgrade - which didn't make Kdenlive usable again. After downgrading back to 0.9.2 (mlt: 0.8.2) the audio and video is really badly out of sync. Not only in the preview, but also after rendering. Funny thing: I chopped the audio-tracks at their beginning and kdenlive does play the chopped part, which it shouldn't. Oh, and when i seek through the playing preview, the sound just continues playing like i wasn't seeking, while the video jumps to the correct position.

By the way: I tried using melt (both versions) to play videos, it worked like a charm.

Some more information about my system: 8 GB Ram, 3,2Ghz Quadcore (Intel i5), 2 graphic-cards (both nvidia, one GeForce GTX 295, one Quadro FX 580), using Gentoo (last synced: two days ago or so), using pulseaudio, but tried starting Kdenlive with pasuspender.

As you probably can imagine, i can't use Kdenlive like this. I really hope, someone can help me.

What happens with new projects? Also what source files are being used? Also what version of ffmpeg?

As an aside I used 'unstable' Gentoo for a number of years in the early days and spent more time trying to fix stuff than actually using it, so your problems bring back memories. Not to say it's like that now and no reflection haven't used it for a long time. Just brought back memories. :-)

I just tried creating new projects, but it doesn't fix the problems. Tested both versions.
But i just found out something different. 0.9.4 seems to have problems with multiple audio tracks. When trying if a new project helps, I used only one audio track at first and the problem with the preview was gone. Haven't tested rendering yet, though. And unfortunately it wouldn't really help me anyways as I need the 2 audio tracks.

The sourcefiles being used are MP3s and mpeg2-encoded avis. ffmpegs version is 0.10.3 and it hasn't changed when I did the update, as my notebook, where I haven't changed to unstable yet, has the same version.
By the way, on my notebook Kdenlive runs fine. If all else fails, I could use it to render my videos, but my computer has more power, better graphiccards, more Ram... I really do want to get Kdenlive running again on this machine ;)

Thinking about it I did have issue with multiple audio for a while, as I use git builds these things get fixed, are you able to build kdenlive / MLT from source using the build script and test that?

Sure. I'll give it a try and report back. :)
[EDIT:] Compiling the git-Versions of mlt and kdenlive fixed the stuttering, but now I know for sure: The audio is out of sync, when I don't play the preview from the beginning. Which is a problem, because I need to be able to cut the video into shorter pieces and for that I need to hear the audio in sync with the video to decide, where I can cut. Therefore, I have to jump back and forth.
I just tested rendering: It is working again, it doesn't consume all my RAM anymore, but the audio is out-of-sync like in the preview :(

So the git build works. Audio scrubbing is available if you have OpenGL playback activated in kdenlives config.

So audio is out of sync, you may need to use kdenlives proxy feature for playback, proxies are not used at render time unless specifically activated in the render dialogue.

I have never used or needed proxies before, but I will give it a try. Hopefully it will help. I'll edit the results, when I'm finished testing around.
[EDIT:] Proxies unfortunately did not help the out-of-sync problem. :(
[EDIT2:] Also, I tried OpenGL on (like it already was) and off, but I can't really see or hear any difference.
But I found out something else: The difference between audio and video seems to be deterministic. I have one particular part of the project where I usually check, if the sync is back and it seems to me, that the audio I hear is always the same, although it is "from the future". Also, if I have two audio tracks, both seem to stay synchronized to each other. But still, they are only synchronized to the video, if I start the preview (or rendering) from the beginning of the project.
Maybe the offset from where the audio should be played/rendered is calculated wrong? Or something like this?

You could try decompressing your mp3's to uncompressed wav to see if it's a problem with mp3 playback in MLT. Or does all this work on your laptop?

OpenGL should allow audio scrubbing, does for me via hdmi. NVidia.

It does not only work on my laptop, it worked before all the updating on this computer as well.
I'm not sure though, what audio scrubbing is as english is not my first language. If this: is accurate, then it seems to me, audio scrubbing is enabled with and without OpenGL. At leased it can't hear any difference and what I hear is similar to what the article describes. But audio scrubbing is not the problem, is it? I thought audio scrubbing and the out-of-sync-problem were two different things.

Still, I will try using uncompressed waves and see if it makes any difference. But unfortunately not right now, I hope to be able to test this in a few hours. If anyone has more ideas, I'd be glad to hear them and test them all later on. Thanks in advance!

Sorry to confuse, I mentioned audio scrubbing because you mentioned " I need to hear the audio in sync with the video to decide, where I can cut." and yes sync'd audio would be good. :-) and audio scrubbing can aide cutting, but if you already have it and others have not then lets forget audio scrubbing. :-)

Looks like Gentoo unstable has introduced some incompatibility with audio libraries, as you don't have the audio sync problems at all on the notebook.

Okay. I just converted an mp3 I use to wav and tested, if using wavs would help: It doesn't. I still have the problem of getting out of sync.
So as I wrote in my opening post, I tested downgrading mlt and Kdenlive, but I am starting to believe, the problem might be another package. ffmpeg hasn't changed version, but are there other packages, which mlt or Kdenlive use for previewing and rendering? If I knew those, I could check, if their version change and try downgrading them.

SDL I think is used for playback in kdenlive.

All installed packages, that contain sdl in their names, haven't been updated since I installed my system in january and the versions match those on my notebook. Unfortunately sdl seems to be a dead end... :-(

Yes! I found, what caused the sync-problems! It was the latest version of ffmpeg. Installed was media-video/ffmpeg-1.0.4, downgrading to 0.10.3 (which is the version on my laptop) solved the problem.
Funny note, though: virtual/ffmpeg has always been on version 0.10.3, as there don't seem to be virtuals for the higher versions of ffmpeg. I don't know, why that is. But as said: Downgrading media-video/ffmpeg back to 0.10.3 helped my, so my problem is solved! Thanks for your help, yellow! :)

That's great, glad to hear you solved the problem.