Cbreak: Free commercial remover for AVI files

Remove commercials from recorded TV quickly and easily

By Nathan True (cbreak@nospam.co.uk@natnonspammingetrue.com)
NEW: Learn how to convert your recorded MPEG files into AVI, completely lossless and very fast!
Download Cbreak right now! (or read on, whatever)

Cbreak is Free Software, but if you feel guilty making use of my blood and sweat without paying, you can make a small (or large!) donation.

About Cbreak

I always wanted one of those personal video recorders, like a Tivo or replayTV or something. With one of those, I could stop being a slave to the clock, always watching the time so that I could drop whatever I was doing to watch the latest episode of Cheat Commandos.

Needless to say, I was getting fed up with it. I had two choices: either give up TV altogether, or find some way to make my own Tivo equivalent.

Of course, I didn't really need to do that whole pause-live-TV thing. So I just went out to by a nice, cheap TV tuner card for my computer. With that in hand, I set up the included scheduler to record all my favorite shows (like The Daily Show with Jon Stewart) to AVI files.

This all worked out nicely, for a while.

And then I got mad.

Well, not mad. Just annoyed that I had to always step through those blasted commercials.

I began searching for a way to have my computer remove the commercials for me. After a while, I realized that commercials are punctuated before and after with a little bit of black space in the video stream. That meant that I could make a program that scans for these and automatically drop commercials from video files.

That's when I said "Sweet!" and went to work.

When all was said and done, I had a highly useful commercial removal utility. The source code is included, so feel free to grab it and make modifications, redistribute, etc. I release the source code to you under the terms of the GNU General Public License (GPL). I also ask that if you make any substantial additions to it, that you let me know so that I can put your variation on this page too.

How Cbreak works

Cbreak works by scanning every frame of a video file, taking note of any black frames in the video. It uses these frames to divide the video up into segments.

Once the segments are established, it has two modes that it can operate in:

When all this is done, it copies the good video segments into a new AVI file along with the corresponding audio. Pretty great, huh? You can also change any of the parameters Cbreak uses to make decisions about a video stream, so it can be adjusted to your specific needs.

Using Cbreak

I included a batch file in the distribution that you can just drag and drop files onto, to have Cbreak run with default options. You can edit the batch file to set your own options.

Usage: cbreak infile outfile [options]

Convert MPEG into AVI lossless and fast

Okay, I've been getting a lot of e-mails asking whether Cbreak can be modified to work on MPEG files, since that's what most TV recording programs use. I definitely don't have the time to add MPEG functionality to Cbreak, but I can give you these instructions for a lossless conversion.

Basically all that happens is the MPEG container is stripped and all the video/audio data is put into an AVI file without re-encoding it. Then, with the proper codecs installed and configured, you can use Cbreak on the resultant AVI files! Here's how:

Step 1: Get the necessary codecs

Since MPEG/MPEG2 in AVI container is a very rare encoding scheme, most computers won't be able to play them (and if you can't play them, Cbreak can't decode them). So grab the codec ffdshow from AfterDawn.com (if you haven't already) and install it. Afterwards, navigate to its Start Menu folder and choose "VFW codec configuration". In the Decoder tab, under Codecs, find MPEG in AVI and change "disabled" to "libavcodec". Hit OK and your system is primed to play MPEG in AVI files.

Step 2: Get ffmpeg

ffmpeg is a wonderful command-line video/audio encoder. You can grab it here (you'll need 7zip to extract). Download and extract it to a folder as you are accustomed. Make sure ffmpeg.exe is somewhere in your PATH (or in the same folder as cbreak.exe) if you're using the batch file below.

Step 3: Convert your MPEG file

Starting here are the parts that you need to do per-MPEG file you want to Cbreak. Fortunately they're all commandline so you can just add them to the Cbreak batch file. You need to put each MPEG into AVI like this:

ffmpeg -i "input-file.mpg" -acodec copy -vcodec copy "output-file.avi"

This command will run very quickly as it's just copying data from the MPEG file to AVI. From there just run Cbreak on it as normal.

The new Cbreak batch file

Now that you've read all these instructions, you can download the new Drag-n-drop batch file which will do the conversion for you, provided you've followed steps 1 and 2 above.

Closing remarks

Here's the download link again. Enjoy!
Also, see more of my works at devices.natetrue.com

Copyright © by Nathan True. All rights reserved.