how to join avi movies
Sunday, January 20th, 2008mencoder -oac copy -ovc copy ./file1.avi ./file1.avi -o ./out.avi
That example may not place keyframes in- (you know how you use the arrow keys in mplayer to forward or rewind?)
For an example that would put in keyframes:
mencoder file1.avi file2.avi -oac copy -ovc lavc -o out.avi
For closer together keyframes:
mencoder file1.avi file2.avi -oac copy -ovc lavc -o out.avi -lavcopts keyint=5
This would change your output quality.
If you get an audio encoding error, you may have to choose an audio codec..
mencoder file1.avi file2.avi -oac pcm -ovc copy -o out.avi
If you don’t want to deal with keyframes, simply use the -forceidx option when you play the movie
mplayer -forceidx ./out.avi
What is mencoder?
mencoder is part of mplayer, you can install via yum on fedora core packages (as root)..
yum -y install mencoder
I had a lot of these to join.. so..
I made a perl script that I can use use without so much fuss.. one that I don’t have to tell it what the output file is going to be.
I put it in ~/bin/avijoin
#!/usr/bin/perl
use strict;
my $outfile = outfile();
my @arg = (qw(mencoder -oac copy -ovc copy), @ARGV, '-o',$outfile);
system(@arg) == 0 or die($?);
print "Wrote:\n$outfile";
exit;
sub outfile {
@ARGV or die('missing args');
my $outfile = $ARGV[0];
$outfile=~s/([^\/]+)\.(\w{1,5})$// or die;
my ($filename,$ext) = (uc $1,$2);
my $x=0;
$filename=~s/\W//g;
my $_outfile;
for(1){
$_outfile="$outfile/$filename$x.$ext";
last unless -e $_outfile;
$x++;
}
return $_outfile;
}
Make sure to chmod 0755 ~/bin/avijoin