PDA

View Full Version : HOWTO: easily join separate mpeg files into one file.


fleshnblood
November 3rd, 2005, 12:02 PM
To join separate mpeg files (for example a movie) into one smooth mpeg file:
cat file1.mpg file2.mpg file3.mpg... > filename.mpg
Pay attention to the order of files after the cat command, it will determine the sequence within the final file.
This will ONLY join the files! It has NO EFFECT on the quality.
It DOES NOT work with AVI files!

poptones
November 3rd, 2005, 12:44 PM
Actually, it does work with avi files or ANY files split with something like hjsplit.

It will also work on ANY AVI files so long as you have mplayer installed. After joining some arbritrary group of AVI files via "cat," tell mplayer to rebuild the index

mencoder -forceidx -oac copy -ovc copy infile.avi -o outfile.avi

fleshnblood
November 3rd, 2005, 01:00 PM
Actually, it does work with avi files or ANY files split with something like hjsplit.

It will also work on ANY AVI files so long as you have mplayer installed. After joining some arbritrary group of AVI files via "cat," tell mplayer to rebuild the index

mencoder -forceidx -oac copy -ovc copy infile.avi -o outfile.avi

Thanks for the tip, I haven't tried it through mplayer. When I joined AVI files with cat, the final file was OK in terms of picture but the audio was shifted. So I guess mplayer fine-tunes it, right?

poptones
November 3rd, 2005, 03:53 PM
I will try. If a file is made with MP3 (especially vbr mp3) it may not be able to do so. MP3 doesn't have a fixed frame size and so is ill suited to video soundtracks, but that doesn't stop people from (mis)using it.

If you cannot get audio and video to synch (because someone made the audio mp3) an easy way to correct this is to save the audio to a file as pcm, then use mplayer to add it back (you can specify separate audio and video files). I use 4 bit ADPCM for audio - it's larger than MP3 but it is fixed size, synchs perfectly, and the distortion it adds is much more tolerable than the darth vader whooshing added by mpeg codecs.

bluebyt
November 3rd, 2005, 07:35 PM
Thank you very much! I was looking for that since I installed Ubuntu 1 month ago.

cat Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.001 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.002 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.003 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.004 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.005 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.006 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.007 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.008 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.009 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.010 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.011 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.012 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.013 > Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg
bash: syntax error near unexpected token `('

Where is the syntax error, please?

fleshnblood
November 5th, 2005, 08:02 AM
I will try. If a file is made with MP3 (especially vbr mp3) it may not be able to do so. MP3 doesn't have a fixed frame size and so is ill suited to video soundtracks, but that doesn't stop people from (mis)using it.

If you cannot get audio and video to synch (because someone made the audio mp3) an easy way to correct this is to save the audio to a file as pcm, then use mplayer to add it back (you can specify separate audio and video files). I use 4 bit ADPCM for audio - it's larger than MP3 but it is fixed size, synchs perfectly, and the distortion it adds is much more tolerable than the darth vader whooshing added by mpeg codecs.

Can you please write a "step by step" for the above to get it work.
I'm still very new to these things :)

Thanks.

dude2425
November 5th, 2005, 07:50 PM
Thank you very much! I was looking for that since I installed Ubuntu 1 month ago.

cat Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.001 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.002 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.003 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.004 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.005 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.006 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.007 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.008 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.009 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.010 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.011 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.012 Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.013 > Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg
bash: syntax error near unexpected token `('

Where is the syntax error, please?

Try \'ing before all the ('s and )'s.

Can this method be applied to mp3's like audiobooks?

poptones
November 5th, 2005, 08:52 PM
Ah, you need to read the friendly manual on "cat" :)

Put the sections in one directory, go to your terminal and type "cat Madonna" and press tab. When it autocompletes to "Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.0"
press the splat key *, space, "> Madonna" and press tab again. This time when it autocompletes press backspace so the filename ends with "mpg" Now press enter.

cat Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.* >> Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg

You can wildcard cats and it will automatically group the parts by sequence.

Linux roolz. :)

bluebyt
November 8th, 2005, 05:32 PM
Ah, you need to read the friendly manual on "cat" :)

Put the sections in one directory, go to your terminal and type "cat Madonna" and press tab. When it autocompletes to "Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.0"
press the splat key *, space, "> Madonna" and press tab again. This time when it autocompletes press backspace so the filename ends with "mpg" Now press enter.

cat Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg.* >> Madonna\ -\ Hung\ up\ (live\ at\ EMA).mpg

You can wildcard cats and it will automatically group the parts by sequence.

Linux roolz. :)

Thank you!!!!

cvmostert
December 25th, 2005, 04:00 PM
Hi,

Thank you for the "cat" help... did not know it would be so easy to combine mpg files...

I have another question... i once burned a vcd file but the .bin file was bigger than 700MB and it all fit on the cd? now... i made an image and it was also little big, but did not want to write on one cd...

i used ffmpeg to change a AVI to MPG (vcd) and then made an image with vcdimager... the mpg file grew bigger? ok different compression...

what would be the easiest way to convert AVI to VCD?

thanx... command prompt pleas... :-)

born to suffer!

timczer
December 25th, 2005, 05:07 PM
If you have transcode installed you can use avimerge to merge multiple avi files together: avimerge -o big.avi -i file1.avi file2.avi file3.avi

As for converting the avi to vcd, avidemux is a good program for this. It will allow you to convert the file, and choose the bit rate in order to ensure that the outputed file will fit on a cd or dvd (whichever you choose). I used this tutorial: http://forum.videohelp.com/viewtopic.php?t=242455 to convert some avi movies into dvd format. There is an option in the conversion dialog to convert to vcd.

cvmostert
December 25th, 2005, 05:16 PM
thank you! i will try it out... and.. merry christmas!

raggamuffin
December 25th, 2005, 05:36 PM
you can also use mpgtx (install it via APT)...

then just " mpgtx -j file01.mpg file02.mpg -o output_name.mpg " ...

Pete051
July 3rd, 2006, 01:51 PM
I've just tried this on realmedia files on dapper, it doubles the file size but dosen't join the files simply over writes one why the file size increase I don't know. anybody any ideas on how to handles realmedia files?
Thanks

DirtDart
July 3rd, 2006, 02:51 PM
It will also work on ANY AVI files so long as you have mplayer installed. After joining some arbritrary group of AVI files via "cat," tell mplayer to rebuild the index

mencoder -forceidx -oac copy -ovc copy infile.avi -o outfile.avi

Sweet...this will come in handy; thanks for the info.

DonVla
October 11th, 2006, 06:01 AM
or easier:

mencoder -oav copy -ovc copy -o output.avi 1.avi 2.avi