Audio Video Sync issues v20.02.17

I have researched the whole forum and google for the answer. My system is an AMD based Ryzen 2700 on an ASUS B450-Strix motherboard. I am running Kubuntu 19.10 with Xanmod kernel 5.5.15 and all video I used was shot on a Go-pro Hero 4 and audio was recorded on a seperate system with wireless mic and Audacity. I am posting here as this bug is real, but here is the solution found by user: JonRay see link.

What I have done is to take the original mp4 files for the video and re-encoded with handbrake to the Production Standard to make them editor friendly which also makes them constant frame rate, even though mine already were. My audio was editied and exported as.ogg files in Audacity also at a constant bitrate not variable.

When syncing the videos and audio in the timeline they playback perfectly synced. When exporting though they become out of sync. Hardware encode is turned on VAAPI for h264 and hevc, but it is clear the CPU is doing all the work because all 16 cores are taxed and the output format I am using is .mov and not either one of those two. I am not having any speed issues or quality issues with the encode just the audio out of sync. It happens whether the video is 2 minutes long or 10 minutes long. I tried breaking down the 10 minute video into 2 minute chunks and that didn’t help. What did work and has worked every time without having to split videos apart as separate Shotcut projects is the above post I linked.

Once the video and audio are synced on your timeline then set the zoom pretty high and and move the playhead by 6 frames and then snap the audio to the new position. Start at the end of your tracks if you have multiple audio tracks on the same project. This has worked Every Time. Please admins let me know what other info you need as I can provide whatever other info to help you solve this bug.

Would you be willing to try two tests to rule some things out?

  1. What happens if the project is built without offsets, then exported with Parallel Processing turned off? It’s an option on the Export panel.

  2. What happens if the Ogg audio file is converted to a WAV file, and then a project built and exported using the WAV without any offsets? Ogg audio is compressed, lossy, and prone to seek accuracy issues. It may be the audio at fault rather than the video. GoPro video is usually pretty solid.

I will get on that for you. Funny thing is I recorded in .wav format and started initially with .wav files so I can mix with those. That was this past Saturday all wave files and same sync issues. It was started in KdenLive first and that’s what moved me to Shotcut as I could not get KdenLive to work either, plus their forums were not as active as Shotcut. I am really liking Shotcut as I use it more anyway.

I will report back this evening with the results exactly as you have requested.

Excellent, those results will help a lot. If neither of those tests make an improvement, the next test would be trying an export without hardware acceleration. VAAPI shouldn’t make a sync difference, but technically it’s possible. The libx265 encoder would be the software equivalent to your hardware settings.

Are you wanting me to keep the export type the same as I have been using, only difference, per your request on each test?

image

Hmm, is your export format really ProRes 422? I’m not aware of any hardware acceleration for ProRes. If you are using h264_amf/nvenc or hevc_amf/nvenc, then yes, those would support hardware acceleration. Regardless, the output codec should be immaterial.

The other settings should be fine as well.

Hey Austin. Yes that is the format I have been using as I find it has really good quality that matches my source, that I can then use handbrake to re-encode to standard web 1080p. As stated in my first post I did not believe there was any hardware acceleration actually happening as all cores (16) were pegged. I will turn those hardware accelerated settings off and parallel processing off just to rule out and test as you have requested.

Hardware acceleration only works for specific codecs, currently H.264 and/or HEVC. Look in the Configure dialog for it. It is OK to leave it on while using a non-accelerated codec.

Thanks. I will repeat the test as asked and will report back on the situation to see if anyone of those items resolve this easy to workaround bug. I work in the support industry for online training and know how to do things exactly as asked.

You have definitely been an ideal question-asker so far! :slight_smile:

1 Like

Okay. 30 second intro clip audio is in sync. here are the video parameters and then the export parameters. There is no re-encode with handbrake on this go-pro clip in the playlist now. The video played back in now slightly choppy as if there are some dropped frames compared to before. No effects, no transitions used either. I just aligned audio and trimmed. Next up is the 10 minute video.
Log file attached also. Noticed some audio error. shotcut-test1.txt (2.2 KB)

What does that mean?

In the log

[consumer avformat] error with audio encode: -541478725 (frame 1114)

This video is out of sync with audio even though on timeline it is in sync. Encoding with Parallel processing turned off is definitely faster than with it. This next and longer video starts off, out of sync, by one second and as played goes out of sync further by at least 2 seconds. I will test next with the original media converted by handbrake while keeping the audio as .wav. Looking forward to the next recommendation from you… Take Care

Attached is the log for this one and I even did a VQ analysis and I am attaching this also. I don’t know if it will help but here it is.

shotcut-test2.txt (2.2 KB) shotcut-test2-VQ.txt (637.9 KB)

I interpret this as saying the “sync offset” is getting greater over time. As in, a simple one-second offset at the beginning wouldn’t fix it because the offset becomes 2 seconds and then probably longer as the clip goes on. Is that what you’re noticing? Because if the amount of sync-drift is not a fixed amount, that kinda implies the audio is sped up or slowed down in order to make the drift get worse. Do you notice a pitch shift in the exported audio compared to the original audio, or in comparison to the GoPro audio (if they recorded the same thing)? As in, do voices sound lower and deeper compared to the original? Do any of your clips have speed or pitch alterations applied on the clips’ Properties panel, for slow-motion work for example?

Your assumptions are correct. But remember I did complete 4 videos today without issue as long as I offset the audio by 6 frames on every project. So the absolute part is that there is a work around, but what is causing myself and the other two users to have to use it is all the question. I want to get to the bottom of it as I plan on using shotcut a lot. All the audio .wav or .ogg has these affects applied to them in Audacity. First is the de-noise effect. Then there is the EQ effect applied to remove the bass out of my voice and then lastly the normalize effect reducing by 10 db. Let me try from a baseline of nothing done to the audio or video just to start eliminating variables and then I will do one thing at a time to see what if any has an affect on the outcome. The audio recordings were done with a Windows 10 machine. All the editing is being done on my linux machine.

That error code is FFmpeg saying “unexpected end of file”. I assume the batteries didn’t run out while the GoPro was recording? Also, that error can mask an underlying error of “specified stream not found”, such as a Handbrake conversion where stream IDs were not preserved.

This error is pointing to a corrupt source file. Did this error happen with the original files or with the Handbrake conversions?

Let’s see if I’m tracking this right…
If the audio is offset by 6 frames, it stays in sync the entire time.
But if the audio is not offset, it can drift by over two seconds?
That’s a head-scratcher, because the audio would need to play back at different speeds for that to happen.

Thanks Austin for your diligence. The batteries were charged in between shooting and never once did the camera die unexpectedly. These log files are with the original source file from the go-pro. I will re-export my long video project that has the 6 frames offset, and get that log file. That one is using the handbrake material. SO, my next question is for future: Is there a recommended camera as I don’t like the go-pro quality anyway, that is hobbyist grade and is one that can take a balanced microphone input, We are looking for future as to use something better. $1500 price range.

Also something I have noticed is that the audio duration is longer than the video duration value even though on the timeline they are both starting at 0 and then end of the two files are trimmed at the exact same spot so they cut off together. is there something I am not resetting after trimming and aligning?? Maybe it is the frame rates being used and there is a rounding issue by the end.

Do not worry about this error. It is not in the source file decoder. It is in the encoder when using PCM for audio and at the end of the file. There is a technical detail that I will spare you.

I tried to reproduce this by working with a 30 minute video with lots of talking head dialog. I extracted audio to WAV in both 48 and 44.1 Khz to test each. Then, I put the video on the timeline, muted it, and added the audio to an audio track and exported as ProRes 4:2:2.

There are some other bug reports claiming the audio in Shotcut preview is delayed by a few hundred milliseconds. I have not seen that either, but it is system dependent. If you have this problem and use preview to sync a distinct audio with a video, then it is going to cause a problem with a constant offset throughout.