Merge AVI files with partial sound tracks

374 Views Asked by At

I need to merge two AVI files where sound tracks are substantially shorter than video ones - i.e. it can be minutes of video without sound at the end. When I merge either with transcode or mencoder, the sound and video are merged together "independently", so I am resulting in an AVI file where all the audio is glued together and all the silence is also glued together and put at the end causing enormous loss of sync between audio and video. Is there any way to merge those files so that the file boundaries are left intact and sound is attached to the proper video frames? I need a Linux command-line solution.

EDIT: Here is the code I am using:

avimerge -i file.avi file2.avi -o result.avi  
mencoder -oac copy -ovc copy -o result.avi file1.avi file2.avi
1

There are 1 best solutions below

2
On

There is a tool in the Ubuntu repository called avidemux which seems like it should do what you need.