Video lagging behind audio after I put it into Shotcut - FIXED

So I’m not sure what to do here. I’m trying to compile all the cutscenes from the one game i play into 1 video for YouTube. All my videos play normally without issues, but some of the videos start desyncing their video and audio after i open them in Shotcut. It’s almost as if the video is play a few frames slower than the audio and i don’t know how to fix it. It “refreshes” when i move to a new section of the video, but the sync just gradually decays and after a couple seconds they’re completely out of sync again.
I’m still new to video editing, so any advise would be appreciated.

EDIT: Okay, so before my video i want to edit has even touched Shotcut, its sync is PERFECT. The video is in mp4 format. After opening it in Shotcut however, the sync gradually decays, with the video playing slightly slower than the audio. About a minute into the clip, and the video is 3-5 second behind the audio. 2 minutes in, and it’s 10 seconds behind the audio. My OS is Windows 7

Presuming the frame rate under Settings > Video Mode is set to match your material (if it doesn’t, Shotcut can mess with the audio - though it should do so in ways that keep it in sync at least)…

Can’t say I know for sure, but do your videos happen to have a variable frame rate?
( check the Properties tab, Video sub-tab - Frame rate should be listed there )

If they do, try converting one first (same tab, hamburger menu, “Convert to edit-friendly…”) and see if the resulting clip does play back right.
In fact, even if they don’t have VFR - try that… in case it’s some other quirk, though it’d be good to have a sample file in that case.

That “convert to edit friendly” didnt work. It still desyncs

There is not much information to go on to help you. Specifics would be great. Please read this post: Requesting Support

I edited my post. Hope the added info gives you a better understanding

Are you able to share one of the video files (hopefully you have some smaller ones that exhibit the issue) so we can check if we run into the same issue and, if so, see if there’s some way of adjusting/converting them so that the issue does not occur?

I cant share the file. I’m greeted by “Sorry, the file you are trying to upload is not authorized (authorized extensions: jpg, jpeg, png, gif, ico, tiff, tif, zip, pdf, txt, mlt, edl, rpt, log).”
The file is mp4. All my files are

Ah, try putting it into a ZIP archive - though I’m not sure what the file size limits for the forum are either. Alternatively, try uploading to a file host, e.g. https://nofile.io/
edit: just don’t upload it to a video host like YouTube, as they’ll convert the file

You mean like where I downloaded my clips after my console uploaded them into the cloud? http://xboxdvr.com/gamer/reapingphant0m/video/55246132 Downloading the clips off there usually puts them into mp4 format by default.

The audio desync doesn’t affect all the videos I put onto shotcut, just some. Though it seems the longer the video the more likely the desync will occur.

EDIT: This is going to be my main challange when i merge all the videos into a single hour long video

Yep, that’ll do!

I can also confirm the video lagging behind the audio as it plays. It’s fine when seeking.

It’s something to do with the video that’s freaking the decoder out - in Shotcut, FireFox, Chrome the desync happens. VLC also plays it back oddly, periodically inserting a very short pause in the audio to keep things in sync.

ShotCut doesn’t detect it as being variable framerate - mediainfo does. Not sure which to believe, but if it is a VFR video that isn’t recognized as such, that would certainly make sense. MediaInfo suggests a minimum of 15.424fps and a maximum of 526.316fps. Ouch.

Unfortunately I can’t think of an easy fix within the Shotcut/ffmpeg confines other than exporting the video with a different frame rate setting (turning it into constant frame rate), importing it, then combining it with the original audio.

How much control do you have over the encoder - i.e. the thing that records your gameplay? If that could be forced to use a fixed frame rate, that would almost certainly help you in many ways for future recordings.

And there lies the root of my problem. The Xbox DVR program, Upload Studio. I have little control over how it records and I’ve noticed now while i was waiting that the videos record in either 29.970 frames per second or 29.965. It’s not consistent. The videos play normally if i simply download them, but as you said, Shotcut has trouble with them because of the inconsistency.

I’ve had numerous problems with that recorder in the past and both DVR and Microsoft support are about as useless as you’d expect.

Welp, I appreciate all you’ve done to try help me. I’ll try do some digging to see if there are other recording apps i can use that are more reliable. Thanks again for your time

No problem. I’d imagine there’s got to be some combination of ffmpeg flags to at least stop sync from drifting, but you’ll still have some of the other audio issues. E.g. the first time REAPINGPHANT0M speaks “No. The codes are in his memory. If I can get close …” actually comes out as “No(cut off short). The codes are in his memory. If I can-can get close …”

I wonder if the culprit is Upload Studio, or the actual recording. I just did a cursory googling and seems Upload Studio will re-encode every recording even for basic things like a name change? Some people are saying you can upload from the YouTube app. If that’s an option for you, give that a shot, see if that keeps sync properly and without audio issues. If so, you can then still download from YouTube for editing.

Good luck… sadly it seems you might need it.

I FOUND A FIX. Since the video to audio sync decay is only noticeable every 10 seconds or so, i decided to split the video every 10 seconds, essentially forcing it to refresh and keep the sync level. There is a feint echo as the audio moves from one clip to another but it’s negligible.

I’ve tried a couple of ffmpeg command line options (outside of shotcut), but always ended up with either the same issue or gaps in the audio, even though it should be able to resample the audio to fit the video, or change the video frame rate (forcing it first to a fixed frame rate) to match audio, but can’t say I got that to work cleanly.