Aug
15
2006

How to join multiple .avi or .mpg files

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: , , , , ,

How to join multiple .avi or .mpg files

Originally from ArsGeek by arsgeek

13 Responses so far

  1. Naushad September 26, 2007 11:37 pm

    Dear Friends,
    I downloaded 7 files lndTinTwa.avi.001 to lndTinTwa.avi.007. Please help me how to join all these 7 files together. Please write me on name786@hotmail.com.

    Thanking you and expecting a postivie responce.

  2. pravin November 5, 2007 5:56 am

    don’t you think you ought to attribute the source? http://www.arsgeek.com/?p=435

  3. pravin November 5, 2007 5:57 am

    my bad. commented on the wrong article. another article has ripped this one off.

  4. taret November 7, 2007 11:30 pm

    Hi Naushad,

    I thinks thats a parted compressed file. Try rar.

  5. David December 28, 2007 12:21 am

    @naushad: Google for HJ-Split

  6. guille February 5, 2008 6:20 am

    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#

  7. Mike April 17, 2008 4:24 am

    Nice guide. A better way to do this without having the AVI intermediate (and saving hard disk space and time) would be to:

    cat b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi | mencoder -forceidx -oac copy -ovc copy - -o bloodspell_final.avi

  8. John June 27, 2008 11:44 am

    From the mencoder manpage:

    -forceidx
    Force index rebuilding. Useful for files with broken index (A/V
    desync, etc). This will enable seeking in files where seeking
    was not possible. You can fix the index permanently with MEn-
    coder (see the documentation).
    NOTE: This option only works if the underlying media supports
    seeking (i.e. not with stdin, pipe, etc).

  9. Andre July 31, 2008 12:59 am

    Thanks for the great tip.

  10. [...] files it causes a breakdown in the sync between video and sound. This error I discovered here (http://techtips.chanduonline.com/2006/08/15/how-to-join-multiple-avi-or-mpg-files) As the tutor says, we need to use mencoder to correct this sync problem. Mencoder is part of [...]

  11. Jesus Christ... December 19, 2008 3:28 am

    # mencoder -forceidx -oac copy -ovc copy b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi -o bloodspell_final.avi

    … Rocket science

  12. ikari December 20, 2008 3:09 pm

    Wow, man, i never thought it’s gonna be THIS simple and… work.
    But it does.

    Thx!

  13. red February 26, 2009 4:07 am

    Wildcards work for filenames…

    mencoder -forceidx -oac copy -ovc copy b?.avi -o bloodspell_final.avi

Leave a Comment

Name (required)

Email (required)

Website

Comments

2006 (c) Tech Tips, Using the ReviewSaurus Theme : Powered by WordPress