Sunday, April 21, 2013

Convert flv clips to mpg and Combine To Make One Long Video.

I had a ton of flv files on my computer and I decided I wanted to convert them to mpg files and then combine them to make a large compilation video. Each video was approximately 5 to 15 minutes in length and I wanted one complete video that ran a little over an hour. Here's what I did.

I found two programs that run from the command line that were perfect for the task at hand. The first program I found was FFmpeg, this program is capable of taking the flv file and converting it to mpg or avi, and I think a couple other formats as well. The other useful program I found was mpgtx, this program is capable of taking multiple mpg files and then combines them to make one giant video file.

It's important to note both these programs have other uses, and I'm barely scraping the surface of what these programs are capable of with this post. However, if your looking to accomplish the same type of project this short post should at least get you headed in the right direction.

Using Fedora I downloaded both programs using yum.

su
yum install ffmpeg


and then

yum install mpgtx.

Yum found the programs, found the dependencies, and installed with no problem. I believe both these programs are also available at sourceforge.net

I then created a directory in my Videos folder and named it project, I copied my flv files that I wanted to work with to that directory. Then using Konsole I went to that directory.

cd username/Videos/project

I then attempted to convert the files with ffmpeg. The first attempt I made was using the basic commands and settings. The program worked great but the video was a bit grainy. FFmpeg is very verbose while it converts the files so I looked at the files pixel size, and then decided to do an exact copy of the video and sound which fixed the image quality but made the video choppy. I then did a bit of research and settled on :

ffmpeg -i filename1.flv -target ntsc-dvd -b 2000k -acodec mp2 -ar 22050 -ab 64k -aspect 4:3 filename1.mpg

For the sake of not writing a dissertation on this program I'll add some links at the bottom as to the different commands and attributes and you can do your own research. The above command however really took care of my problem. The video was converted to about the same quality as the original, no more skipping in frames, and the sound quality seemed perfect. After this I took about nine flv files and simply repeated the above process with each one.

Now that I had the flv files all converted I then used mpgtx to combine them into one video. This couldn't of been easier. I simply used the following command and mpgtx did the rest.

mpgtx -j filename1.mpg filename2.mpg filename3.mpg filename4.mpg filename5.mpg filename6.mpg -o yourOutputFilnameHere.mpg

This combined all the 5 to 15 minute clips into a 1 hour and 7 minute video. There was no reduction in quality that I noticed and overall I was very pleased with the end result of this project.

As I stated earlier I could write a dissertation on the use of these two programs. This post was not meant to be a tutorial but simply a review of the programs, the basics of how they work, and a review of the basic research I did to make the programs do what I wanted for this particular project. For more information on these programs and all they have to offer you can check out the following links.

mpgtx http://mpgtx.sourceforge.net/#Examples

ffmpeg http://howto-pages.org/ffmpeg/

The above links were the two that I found most useful. There is a ton of information all over the web about these two programs so feel free to do your own research. I plan on learning a lot more about these two programs and will probably be adding some more information and tutorials about these programs to the blog.

No comments:

Post a Comment