Archive

Posts Tagged ‘ffmpeg’

Merge avi files with ffmpeg on Mac OS

November 22, 2010 1 comment

Goals: Create one (and big) avi file from multiple or more avi files.
Our option:

  • Use Quicktime Pro, it’s easier but you need extra dollar to buy the account 😦
  • Use FFmpeg 🙂

Install FFmpeg, i’m using homebrew package:

$ brew install ffmpeg

Or if you are using Macports, simply run:

$ port install ffmpeg

OK, for example we will merge file video cd1.avi and cd2.avi. Each have 700MB size.
First, we concatenate them with the magic of cat command.

$ cat cd1.avi cd2.avi > cd_all.avi

Now, you’ll get cd_all.avi with 1.4GB. But wait? is it finish yet (where’s the ffmpeg?), if you open up and watch the cd_all.avi file you’ll get blank screen when the cd2 part is on or even not get to cd2 part, it’s because the video index is broken or only see the first part (cd1). So, it’s ffmpeg job to re-index it 🙂

$ ffmpeg -i cd_all.avi cd_all_reindexed.avi

Opps, i got “timebase not supported by mpeg 4 standard” error. It’s because ffmpeg cannot set the fps (frame per second) automatically from our input, so we need to set it manually, let’s use the default value 25.

$ ffmpeg -i cd_all.avi -r 25 cd_all_reindexed.avi

OK, it’s work, let’s wait about 5-10 minutes (depend on file size) to get ffmpeg finish the encoding and reindexing.

Opps, the encoding stop on “video:177642kB audio:57082kB global headers:0kB muxing overhead 4.904114%” and i only got 250MB and video quality is really bad, there’s something wrong. Ahh, we need to add sameq parameters to preserve same quality as input.

$ ffmpeg -i cd_all.avi -r 25 -sameq cd_all_reindexed.avi

It’s works 🙂 But, the filesize is become 1.75GB, there should be a way to set another paramater to make it 1.4GB (normal size), but let’s discover later :).

Reference:

Categories: Tips 'n trick Tags: ,