Hack 76. Cut Commercials
Use avidemux to quickly and easily cut commercials out of your recorded TV shows. So you have set up MythTV [Hack #77], retrieved shows from your TiVo, or otherwise have some sort of television show in digital form on your computer. One nice feature of a VCR, TiVo, or other video recorder is the ability to quickly skip commercials in TV shows you have recorded. If you have recorded a show in digital format, you can certainly just fast-forward each time a commercial appears, but that requires extra work each time you watch the show. Also, with some time-based recording methods you end up getting a bit of the previous show and perhaps a bit of the next show in your recording in case your clock differs from the TV station's clock. If you plan to archive the show and watch it multiple times, you probably want to crop out all those commercials and bits from other shows. This is especially true if you plan on converting the video to VCD, SVCD, or DVD format, as discussed in [Hacks #69 and #70]. Now, before you get visions of sitting behind a huge sound board or in front of three monitors full of advanced video-editing software, let me say that cropping out commercials is not very difficult or time-consuming if you use the proper tools. After all, if it takes more work to crop the commercials than to watch them, what's the point? With the avidemux video-editing software, and particularly with its "Scan for black frames" feature, you can locate and remove commercials from your videos quickly and without much effort. The first step is to download and install the avidemux software. This step will vary based on your distribution, but visit the avidemux download page at http://fixounet.free.fr/avidemux/download.html and find the precompiled package for your distribution. If there is no precompiled version, then download the .tar.gz source from the site and follow the installation documentation at http://fixounet.free.fr/avidemux/doc/en/install.xml.html to install the software. There are very few definite required libraries for avidemux, it mostly requires GTK+ and glib2.x, libmad, libxml2, and nasmall software that should be readily available on any major Linux distribution. Apart from that, other libraries are optional and only serve to increase avidemux's support for various video and audio formats. Use [Hack #53] to find and install various extra codecs and libraries for your computer.
Once avidemux is installed, launch it from a menu or type avidemux from a console. The default interface has a lot of different options but for your purposes you only need to use a few of them. First click File The simplest way to remove commercials from a program is chronologically. The following method also takes into account the fact that a commercial break might contain multiple sets of black frames in between individual commercials. Since your show probably doesn't have any black frames, it's easiest to move to different sections of the show, then move forward or backward to find black frames that signal new commercials. The first step in the commercial removal process is to remove any commercials or other content from the beginning of the video so your video starts with the beginning of the show. This step is a bit easier than removing commercials from the middle of the video, so it's a good place to start. If your recording already starts at the beginning of the show you can skip this particular step. With the video you wish to edit open but paused, drag the bar along the bottom with your mouse to skip ahead until you find the beginning of your show. Now click Play Repeat the previous step until you reach the end of the show. If there is commercial content past the end of the credits, just seek to the black frame, set an opening marker, then skip to the end of the video, set the closing marker, and delete. After your video is all edited, click File |