RSS

How to join multiple .avi or .mpg files

Mon, Aug 7, 2006

ArsGeek, Just Plain Geek, Linux, Ubuntu

Talk about it in our Forums

I have recently started watching the fab serialized movie Bloodspell, which is created entirely in Neverwinter Nights.

Bloodspell is released in a series of 6-7 MB files. So far they’re up to part 7. This certainly makes it easier to download on to my laptop and enjoy 10 minutes of Bloodspell at a time. However, I want to burn this to a DVD and watch all seven at once on my home DVD player. Before I did this I just wanted to string together the 7 .avi files into one larger file. (I can’t stand a mess!) Sounds like a simple request? Guess what, in my distro, Ubuntu, it is!

This will most likely work on just about any linux distro that includes the ability to install mplayer/mencoder.

First, let’s get the right programs.

sudo apt-get install mencoder mplayer

Now that the hard part is out of the way, we’re going to make use of the wonderful cat command. I’d renamed each Bloodspell video as b1.avi - b7.avi. Now to string them all end to end.

cat b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi > bloodspell.avi

Now we’re 2/3 of the way there! Stringing together .avi files can cause a breakdown in the sync between video and sound. So, we’ll use mencoder to sort things out.

mencoder -forceidx -oac copy -ovc copy bloodspell.avi.avi -o bloodspell_final.avi

That’s it! You’ve got one contiguous .avi file now containing all seven bloodspell releases to date. This will of course work with other .avi files. It will also work with .mpg or .mpeg files as well.

Later we’ll discuss getting this .avi file on to a DVD so you can watch it anywhere.

geek out.

Technorati Tags: , , , , ,

Click the icon, share the link:
  • Digg
  • del.icio.us
  • MisterWong
  • Furl
  • Reddit
  • Technorati
  • BlinkList
  • feedmelinks
  • PopCurrent
  • Blogosphere News
  • Facebook
  • Fark
  • Mixx
  • Slashdot

This post was written by:

arsgeek - who has written 1980 posts on ArsGeek.


Contact the author

16 Comments For This Post

  1. Mr. Pr0n Says:

    This will also work:

    mencoder -oac copy -ovc copy file1 file2 file3 … -o final_movie.mpg

    and please stop talking about ubuntu like it was a godsend, everyone knows that archlinux is much much better :P

  2. arsgeek Says:

    Hey, thanks for the mencoder tip. And what is this Archlinux that you speak of? Damn. Now I’ve got another distro I’ve got to go install and check out. :)

  3. Phil Says:

    avimerge from the transcode package was designed for this task. and as far as i know, it was created before ubuntu. ;P

    avimerge -i b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi -o bloodspell.avi

    http://www.transcoding.org/cgi-bin/transcode

  4. arsgeek Says:

    Excellent suggestion Phil. Thanks!

  5. guille Says:

    How can i fix this¿?

    root@guille-desktop:/home/guille# apt-get install mplayer mencoder
    Reading package lists… Done
    Building dependency tree… Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    mencoder: Depends: libasound2 (> 1.0.14) but 1.0.10-2ubuntu4 is to be installed
    Depends: libc6 (>= 2.6-1) but 2.3.6-0ubuntu20.5 is to be installed
    Depends: libdvdread3 (>= 0.9.6) but 0.9.4-5.1 is to be installed
    Depends: libfontconfig1 (>= 2.4.0) but 2.3.2-1.1ubuntu12 is to be installed
    Depends: libfreetype6 (>= 2.3.5) but 2.1.10-1ubuntu2.4 is to be installed
    Depends: libgcc1 (>= 1:4.2.1) but 1:4.0.3-1ubuntu5 is to be installed
    Depends: liblame0 (>= 3.97) but 3.96.1-1 is to be installed
    Depends: libncurses5 (>= 5.6) but 5.5-1ubuntu3 is to be installed
    Depends: libpng12-0 (>= 1.2.13-4) but 1.2.8rel-5ubuntu0.3 is to be installed
    Depends: libstdc++6 (>= 4.2.1) but 4.0.3-1ubuntu5 is to be installed
    Depends: libx264-54 but it is not installable
    Depends: zlib1g (>= 1:1.2.3.3.dfsg-1) but 1:1.2.3-6ubuntu4 is to be installed
    mplayer: Depends: libasound2 (> 1.0.14) but 1.0.10-2ubuntu4 is to be installed
    Depends: libatk1.0-0 (>= 1.13.2) but 1.11.4-0ubuntu1 is to be installed
    Depends: libc6 (>= 2.6-1) but 2.3.6-0ubuntu20.5 is to be installed
    Depends: libcaca0 (>= 0.99.beta11-1) but it is not installable
    Depends: libcairo2 (>= 1.4.0) but 1.0.4-0ubuntu1.2 is to be installed
    Depends: libcucul0 (>= 0.99.beta11-1) but it is not installable
    Depends: libdbus-1-3 (>= 1.1.1) but it is not installable
    Depends: libdbus-glib-1-2 (>= 0.74) but 0.60-6ubuntu8.1 is to be installed
    Depends: libdvdread3 (>= 0.9.6) but 0.9.4-5.1 is to be installed
    Depends: libfontconfig1 (>= 2.4.0) but 2.3.2-1.1ubuntu12 is to be installed
    Depends: libfreetype6 (>= 2.3.5) but 2.1.10-1ubuntu2.4 is to be installed
    Depends: libgcc1 (>= 1:4.2.1) but 1:4.0.3-1ubuntu5 is to be installed
    Depends: libggi2 (>= 1:2.2.1) but it is not going to be installed
    Depends: libglib2.0-0 (>= 2.14.0) but 2.10.3-0ubuntu1 is to be installed
    Depends: libgtk2.0-0 (>= 2.12.0) but 2.8.20-0ubuntu1.1 is to be installed
    Depends: liblame0 (>= 3.97) but 3.96.1-1 is to be installed
    Depends: libncurses5 (>= 5.6) but 5.5-1ubuntu3 is to be installed
    Depends: libpango1.0-0 (>= 1.18.2) but 1.12.3-0ubuntu3 is to be installed
    Depends: libpng12-0 (>= 1.2.13-4) but 1.2.8rel-5ubuntu0.3 is to be installed
    Depends: libpulse0 but it is not installable
    Depends: libsdl1.2debian (>= 1.2.10-1) but 1.2.9-0.0ubuntu2 is to be installed
    Depends: libstdc++6 (>= 4.2.1) but 4.0.3-1ubuntu5 is to be installed
    Depends: libx264-54 but it is not installable
    Depends: libxcomposite1 (>= 1:0.3-1) but it is not going to be installed
    Depends: libxdamage1 (>= 1:1.1) but 1:1.0.2.2-0ubuntu2 is to be installed
    Depends: libxfixes3 (>= 1:4.0.1) but 1:3.0.1.2-0ubuntu3 is to be installed
    Depends: libxrandr2 (>= 2:1.2.0) but 1:1.1.0.2-0ubuntu4 is to be installed
    Depends: zlib1g (>= 1:1.2.3.3.dfsg-1) but 1:1.2.3-6ubuntu4 is to be installed
    E: Broken packages
    root@guille-desktop:/home/guille#

  6. arsgeek Says:

    guille, what version of Ubuntu are you running this on? Are you using non-stable repositories?

  7. faxm0dem Says:

    Listen to what Mr. Pr0n said. Forget that UUOC and use mencoder directly

  8. Joe Francais Says:

    Try using Jfuse (http://www.jfuse.com). It joins all types of media files.

  9. lalo Says:

    using ubuntu 8.04, with mencoder installer. I joined the mpeg files using cat then encoded both ways first tried arsgeek instructions and joined 1 file, then used Mr Pr0n instructions and made a second file. The issue is that I have sound but no video ? any ideas….. thanks for the help

  10. villate Says:

    lalo: totem movie player does not show the video, but it is there. Try opening the file with mplayer or avidemux. However, there seems to be something wrong with the file created that way: both mplayer and avidemux refuse to fast forward it; I don’t know what causes that problem.

  11. villate Says:

    OK, I figured it out. If you want to merge mpg files you must use this:

    mencoder -oac copy -ovc copy -of mpeg part1.mpg part2.mpg -o all.mpg

  12. nic Says:

    come on… buy a real computer and use iMovie/Quicktime/After Effects/Nuke/…

  13. dnfm Says:

    Yea, what nic said! Blow all sorts of money on inferior crap that’s locked down hard and is prone to breaking just so you can be a fanboy too!

  14. Zee Caniago Says:

    Thanks for the tutorial. it works great ! :)

  15. Azazello Says:

    works great, thanks.

  16. ASG Says:

    Typo:
    mencoder -forceidx -oac copy -ovc copy bloodspell.avi.avi -o bloodspell_final.avi

    Should be:

    mencoder -forceidx -oac copy -ovc copy bloodspell.avi -o bloodspell_final.avi

9 Trackbacks For This Post

  1. collegiuateubiquity » Blog Archive » how to join multiple .avi or .mpg files - the easy way Says:

    [...] read more | digg story [...]

  2. ArsGeek :: How to edit several AVI (or mpeg) files joined together Says:

    [...] Previously we looked at how to join several AVI files together, and then how to burn them to a DVD. [...]

  3. How to join multiple .avi or .mpg files : Tech Tips Says:

    [...] How to join multiple .avi or .mpg files [...]

  4. How to copy a dual layer DVD in Linux : Tech Tips Says:

    [...] Now that we’ve looked at doing various things to multimedia files and burning them to a DVD, let’s examine how to make a copy of a dual layer DVD. If you have a dual layer burner, then there’s no reason to read further. If you’re like me howevever, and you have a single layer (4.7GB) drive and DVDs then this will be a helpful guide. [...]

  5. ArsGeek - Free your inner geek » Bloodspell concludes with Episode 14 Says:

    [...] I’ve made several posts about Bloodspell and working with it’s various episodes. [...]

  6. links for 2007-02-04 at molgar.net Says:

    [...] ArsGeek - Free your inner geek » How to join multiple .avi or .mpg files Cómo unir archivos avi o mpg usando la consola de linux. (tags: video linux ubuntu avi howto mencoder mpeg join) UncategorizedShare This [...]

  7. Pareto :: Rotar video :: April :: 2007 Says:

    [...] ser que necesitemos instalar algunos paquetes, y luego sincronizar el sonido (yo no lo necesité), acá esta el resto. Comments [...]

  8. Just Another Blog » Blog Archive » Samle / joine video filer Says:

    [...] http://www.arsgeek.com/2006/08/07/how-to-join-multiple-avi-or-mpg-files/ [...]

  9. links for 2009-09-28 Says:

    [...] How to join multiple .avi or .mpg files | ArsGeek (tags: linux howto video) [...]

Leave a Reply