PDA

View Full Version : Tip: Join two avi file with mencoder



kd7swh
January 13th, 2007, 12:11 AM
Joining two or more avi files is easy with mencoder.

Here is a simple script that I use to do it:


# MjAVI - 2007
#Mencoder needs to be installed for this script to work
#The Numbers in this script could be changed to combine more than two files.
# Mencoder also supports mpeg files. So the .avi could also be changed to .mpg


echo "Script to combine two avi files, while syncing audio."
echo "usage: ./mjavi a1.avi a2.avi combined_temp.avi final.avi"

cat "$1" "$2" > "$3";
mencoder -forceidx -oac copy -ovc copy "$3" -o "$4"



the cat command combines 1 and 2 into 3, but the audio isn't in sync. So, 3 is indexed with mencoder into 4 which has nicely synced audio. :)

neilp85
February 6th, 2007, 08:59 AM
There's no reason to cat the two files together before encoding because mencoder can handle that as well.

mencoder -forceidx -ovc copy -oac copy -o file.avi p1.avi p2.avi ...

LucasLinard
February 12th, 2007, 05:07 AM
There's no reason to cat the two files together before encoding because mencoder can handle that as well.

mencoder -forceidx -ovc copy -oac copy -o file.avi p1.avi p2.avi ...

When I try to join 2 mpeg files, how can I make the oputput a mpg file?
If I try -of mpeg I get a lot of errores like this one:
ERROR: scr 6715.707, dts 0.000, pts 6714.866

ERROR: scr 6715.752, dts 0.000, pts 6714.962

ERROR: scr 6715.794, dts 0.000, pts 6715.058

ERROR: scr 6715.837, dts 0.000, pts 6715.122

ERROR: scr 6715.885, dts 0.000, pts 6715.218

ERROR: scr 6715.925, dts 6715.283, pts 6715.408

ERROR: scr 6715.927, dts 0.000, pts 6715.282

ERROR: scr 6715.979, dts 0.000, pts 6715.378

ERROR: scr 6716.025, dts 0.000, pts 6715.474

ERROR: scr 6716.066, dts 0.000, pts 6715.538

ERROR: scr 6716.090, dts 6715.575, pts 6715.700
Pos:6716.1s 161028f (88%) 473.28fps Trem: 0min 2904mb A-V:0.066 [2976:192]
ERROR: scr 6716.162, dts 0.000, pts 6715.634

ERROR: scr 6716.210, dts 0.000, pts 6715.730

ERROR: scr 6716.254, dts 0.000, pts 6715.794

ERROR: scr 6716.302, dts 0.000, pts 6715.890

ERROR: scr 6716.358, dts 0.000, pts 6715.954

ERROR: scr 6716.369, dts 6716.034, pts 6716.159

ERROR: scr 6716.371, dts 0.000, pts 6716.050

ERROR: scr 6716.406, dts 0.000, pts 6716.146

ERROR: scr 6716.441, dts 0.000, pts 6716.210

ERROR: scr 6716.485, dts 0.000, pts 6716.306

ERROR: scr 6716.511, dts 6716.326, pts 6716.451
Pos:6716.9s 161046f (88%) 473.30fps Trem: 0min 2904mb A-V:0.055 [2976:192]

DerArzt
February 21st, 2007, 08:41 PM
Cheers neilp85. Worked PERFECTLY.

tzulberti
February 22nd, 2007, 11:00 AM
Thanks for the tip

z987k
March 15th, 2007, 05:01 PM
When I try to join 2 mpeg files, how can I make the oputput a mpg file?
If I try -of mpeg I get a lot of errores like this one:
ERROR: scr 6715.707, dts 0.000, pts 6714.866

ERROR: scr 6715.752, dts 0.000, pts 6714.962

ERROR: scr 6715.794, dts 0.000, pts 6715.058

ERROR: scr 6715.837, dts 0.000, pts 6715.122

ERROR: scr 6715.885, dts 0.000, pts 6715.218

ERROR: scr 6715.925, dts 6715.283, pts 6715.408

ERROR: scr 6715.927, dts 0.000, pts 6715.282

ERROR: scr 6715.979, dts 0.000, pts 6715.378

ERROR: scr 6716.025, dts 0.000, pts 6715.474

ERROR: scr 6716.066, dts 0.000, pts 6715.538

ERROR: scr 6716.090, dts 6715.575, pts 6715.700
Pos:6716.1s 161028f (88%) 473.28fps Trem: 0min 2904mb A-V:0.066 [2976:192]
ERROR: scr 6716.162, dts 0.000, pts 6715.634

ERROR: scr 6716.210, dts 0.000, pts 6715.730

ERROR: scr 6716.254, dts 0.000, pts 6715.794

ERROR: scr 6716.302, dts 0.000, pts 6715.890

ERROR: scr 6716.358, dts 0.000, pts 6715.954

ERROR: scr 6716.369, dts 6716.034, pts 6716.159

ERROR: scr 6716.371, dts 0.000, pts 6716.050

ERROR: scr 6716.406, dts 0.000, pts 6716.146

ERROR: scr 6716.441, dts 0.000, pts 6716.210

ERROR: scr 6716.485, dts 0.000, pts 6716.306

ERROR: scr 6716.511, dts 6716.326, pts 6716.451
Pos:6716.9s 161046f (88%) 473.30fps Trem: 0min 2904mb A-V:0.055 [2976:192]

http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-mpeg.html

Also if you have two mpg's of the same format, couldn't you just "cat 1 2 > 3"?

kd7swh
November 16th, 2007, 07:32 AM
if you just use cat, its my understanding that the index would not be preserved. this process creates a working index.

yabbadabbadont
November 16th, 2007, 07:37 AM
How about just using avimerge which is included with transcode? ;)

Edit: Wow! Holy Thread Resurrection Batman! :D

kd7swh
November 16th, 2007, 07:56 AM
I created this thread almost a year ago, a lot has changed since then.

lad3391
December 3rd, 2008, 07:23 AM
i just found it, and it works great for me. i guess my only suggestion to ppl reading this would be to type in 'cd ~/Desktop' into terminal (if thats where your files are at), no ' symbols, just the stuff between. type that before you do the mencoder command line

tdreyer1
December 12th, 2008, 03:34 AM
mencoder -forceidx -ovc copy -oac copy -o file.avi p1.avi p2.avi ...

Awesome! That worked great! :mrgreen:

deadtom
January 20th, 2009, 05:25 PM
Worked great for me too. Thanks for the info!

Lylex11
June 14th, 2009, 01:48 PM
Thanks neilp85! works a treat and real quick. Saves encoding all the files again!

HarshReality
October 10th, 2009, 01:39 PM
I'd love it if there was a right click option to just run this (mencoder script).. would save alot of typing.

yunone
October 25th, 2009, 05:28 AM
i just found it, and it works great for me. i guess my only suggestion to ppl reading this would be to type in 'cd ~/Desktop' into terminal (if thats where your files are at), no ' symbols, just the stuff between. type that before you do the mencoder command line


thank you very much for the simple tip about the file location...worked perfectly....Great little tip !

kvarley
February 6th, 2010, 12:29 PM
There's no reason to cat the two files together before encoding because mencoder can handle that as well.

mencoder -forceidx -ovc copy -oac copy -o file.avi p1.avi p2.avi ...
Thank you so much! Nice bit of code which has been much use to me. :P

mister_playboy
January 23rd, 2011, 11:21 AM
There's no reason to cat the two files together before encoding because mencoder can handle that as well.

mencoder -forceidx -ovc copy -oac copy -o file.avi p1.avi p2.avi ...

Just what I was looking for... thank you. :KS

vedavrata
January 26th, 2013, 04:16 AM
mencoder can handle that as well.

mencoder -forceidx -ovc copy -oac copy -o file.avi p1.avi p2.avi ... Thank you!
It works! [and much better than by ffmpeg! :)]

andrew.46
January 27th, 2013, 11:21 PM
It works! [and much better than by ffmpeg! :)]

Good to see that you have achieved the desired outcome but have a look at a modern copy of FFmpeg and you might find that there have been some considerable improvements in video concatenation just recently.