Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have tried avidemux2_cli, mencoder, ffmpeg, cat.. But this doesn't always work (With the most of the times the error is that the audio codec is not the same) Maybe i put wrong options in the commands.

So the commands:

cat Sample.avi rrr.avi > complete.avi
ffmpeg -i Sample.avi -i output.avi -vcodec copy -acodec copy complete.avi
mencoder -ovc lavc -oac copy Sample.avi rrr.avi -o complete.avi
avidemux2_cli --audio-codec copy --video-codec copy --output-format avi --load Sample.avi -append output.avi --save video.avi

The cat problem is that it doesn't show error but it doesn't work always..Like the complete.avi will be exactly the same with Sample.avi

Fmmpeg does nothing. The complete.avi is always the same with Sample.avi

Mencoder error: All files must have identical audio codec and format for -oac copy. So the complete.avi is the same with Sample.avi

avidemux2_cli there is no error but the complete.avi is again the same with Sample.avi..

So to sum up, all complete.avi are the same with Sample.avi.. And the problem is that they don't have the same audio codec ( i quess ).. Any ideas?

share|improve this question
I think that you need to change the video codec and audio codec of input files into the same codecs, if you want to combine two videos safely, –  vine_user Jul 8 '12 at 17:27
And how can i do it? –  Leon Vitanos Jul 8 '12 at 17:36
You can use mencoder with -ovc option and -oac option. See: mplayerhq.hu/DOCS/HTML/en/menc-feat-selecting-codec.html –  vine_user Jul 8 '12 at 17:53

3 Answers 3

If you want to combine two videos safely, you need to change the video codec and audio codec of input files into the same codecs.

For example, using xvid (video codec) and mp3lame (audio codec):

sudo apt-get install mencoder libxvidcore4 libmp3lame0

you can encode the input videos by the below commands:

mencoder -ovc xvid -oac mp3lame -xvidencopts bitrate=1000 first.avi -o video1.avi
mencoder -ovc xvid -oac mp3lame -xvidencopts bitrate=1000 second.avi -o video2.avi

To be matched your videos, you can change the options "bitrate" etc. (and also the codecs).

If the encoded video names are "video1.avi" and "video2.avi", and the output video name is "joined-video.avi",

mencoder -ovc copy -oac mp3lame video1.avi video2.avi -o joined-video.avi 

Using this command, you can make the joined video file.

share|improve this answer
Just thought I'd reinforce that the name of this util is mencoder (i.e. Media ENcoder). A lot of people get stuck by accidentally typing in memcoder. –  Val Aug 16 '13 at 5:09

I had to join three pieces of video with identical codecs. Reading the previous answers I managed to do this:

mencoder -ovc copy -oac faac 01.mp4 02.mp4 03.mp4 -o output.mp4

Much faster and simpler than Openshot!

First I tried the '-oac copy' option, but it seems that the audio codec in my videos doesn't allow it. I got an error message recommending '-oac pcm'. The pcm codec is not a good option though: the resulting file is very big and 2/3 of it is uncompressed audio.

Hope this helps

share|improve this answer
MEncoder svn r34540 (Ubuntu), built with gcc-4.7 (C) 2000-2012 MPlayer Team MPlayer was compiled without libfaac. See README or DOCS. –  Philippe Gachoud Mar 22 at 20:42

A solution that I found here helped me to join without loss two mp4 files:

sudo apt-get install gpac
MP4Box -cat part1.mp4 -cat part2.mp4 -new joinedfile.mp4

I tried using Avidemux, but had problems with sound in the merged video.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.