Hi. I have thousands of short video clips (2s to 30s long) that I'm trying to join and the audio always goes out of sync. I'm usually joining 200-300 clips into a single video and the further along in the video the more out of sync the audio becomes.
First I thought it was because not all of the clips have the same audio sample rate. I tried joining only videos that have the same sample rate, but the final video still has sync issues. Then I thought it was because not all the clips use the same frame rate, some are 24fps, 25fps, 30fps, 60fps. So I tried joining only videos that have the same frame rate and same audio sample rate, but it still goes out of sync.
When all the frame rates and sample rates match the sync issue is far less noticeable, but it's still there. Most of the videos were cut using SolveigMM Video Splitter and also to join the resulting clips back together. None of the clips have audio sync issues when I check them individually, only when they're joined together. I tried a few other tools for cutting and merging clips, but the audio sync issue is always there.
Are there any tools out there that can merge the clips and also fix the audio sync issue? Or a tool that can fix individual clips so they won't have sync issues when I join them together? I would prefer not to re-encode the video or audio, but if that's the only way to fix the issue then I would be willing to do that too. Any suggestions would be greatly appreciated.
+ Reply to Thread
Results 1 to 9 of 9
-
-
What is the format of the clips ? Once I had a similar issue trying to join 3 MP4 files losslessly, every method resulted in synchronization issues, except one : with ffmpeg, first converting each clip to TS format (Transport Stream), then merging the clips as TS back to MP4.
Code:ffmpeg -i "input 1.mp4" -c copy -bsf h264_mp4toannexb "temp1.ts" ffmpeg -i "input 2.mp4" -c copy -bsf h264_mp4toannexb "temp2.ts" ffmpeg -i "input 3.mp4" -c copy -bsf h264_mp4toannexb "temp3.ts" ffmpeg -i "input 4.mp4" -c copy -bsf h264_mp4toannexb "temp4.ts" ffmpeg -i "concat:temp1.ts|temp2.ts|temp3.ts|temp4.ts" -c copy -absf aac_adtstoasc "input 1-4 merged.mp4"
Also, I don't know what the "-absf aac_adtstoasc" option does, or if it's still working with recent versions of ffmpeg.
The suggestion above with Avisynth would require transcoding.
Another option would be to join the clips in a non linear editor. -
Thanks for the reply. All my clips are 1080p MP4 (H.264) format. Would the ffmpeg method require that all the clips have matching frame rates and audio sample rates? Any idea if a non linear editor would be able to join different frame rate and sample rate clips without having to transcode the video? What would be a good editor for that? Something like Adobe Premiere or is there something better?
-
Would the ffmpeg method require that all the clips have matching frame rates and audio sample rates?
Or you could leave it in TS, as a quick and dirty workaround, if it doesn't have to be processed further. Just replace the last line by :
Code:"concat:temp1.ts|temp2.ts|temp3.ts|temp4.ts" -c copy -absf aac_adtstoasc "input 1-4 merged.ts"
The particularity of the TS format, as I understand it, is that video and audio streams are organized in small "packets" with a dedicated header, each packet being a self contained unit which can be read individually, so if a packet is missing (typically because of a transmission issue, as it is primarily used for broadcasting), the playback can continue at the next packet, there's only a glitch and the video doesn't stop right there as it would with most other formats, and the video/audio synchronization is not lost (each packet containing a split second of synchronized video/audio streams). And it also allows to join parts with different parameters. For instance I have some TV recordings made in MPEG-TS around 2008 (when the broadcasting standard aspect ratio was still 4:3) which suddenly switch the aspect ratio from 4:3 to 16:9 at the beginning of a documentary. Converting them losslessly to MPEG-PS works (MPEG-PS is also structured in small “packets” with a new header at regular intervals, although I don't know exactly what distinguishes MPEG-PS from MPEG-TS), but if transcoding them to MP4 for instance, only one aspect ratio could be defined for the whole duration of the video.
Any idea if a non linear editor would be able to join different frame rate and sample rate clips without having to transcode the video?
What would be a good editor for that? Something like Adobe Premiere or is there something better? -
@umbala
Are your clips VFR (variable frame rate) from a mobile phone?
If so, convert them to CFR (constant frame rate) before joining them, e.g. using the utility mp4fpsmod.exe or perhaps by remuxing via mkvtoolnix.
or you could try to add to the concatenation commandline
ffmpeg -i "concat:temp1.ts|temp2.ts|temp3.ts|temp4.ts" -c copy -video_track_timescale 60 -absf aac_adtstoasc "input 1-4 merged.mp4"Last edited by Sharc; 7th Jul 2020 at 08:59.
-
@ Sharc
You mean this ? How to make an .exe file with what's provided ? Perhaps there's a pre-compiled version somewhere ?
It might not be relevant to the issue exposed in this thread, but it might be useful to solve an issue I explained there. In short : a MKV video is not read by a standalone BRD player (which normally plays MKV files), most likely because of a "variable framerate" flag, although it shouldn't be variable at all (it's a movie in standard 23.976 FPS), so I need to losslessly process it in such a way that the player can read it. -
Alright, thanks. It's been a long time since I updated it... just did : it's there indeed.
Similar Threads
-
Trying to combine audio clips in AviSynth
By smike in forum EditingReplies: 2Last Post: 1st Jun 2020, 15:29 -
need to sync many audio clips from aac(mp4) to mp3 ,what could i use ?
By rama in forum AudioReplies: 1Last Post: 10th Mar 2020, 11:02 -
Audio sync problem — video goes out of sync after a while
By maxalfreeman in forum AudioReplies: 4Last Post: 12th Sep 2019, 14:07 -
Averaging multiple audio clips?
By Aludin in forum AudioReplies: 26Last Post: 2nd Nov 2016, 22:24 -
VirtualDub audio out of sync, other video players all in sync
By a1s2d3f4 in forum Newbie / General discussionsReplies: 7Last Post: 11th Apr 2016, 22:36