MythTV does not automatically remove commercials. The system will flag commercials and skip them during playback. It can also transcode recordings between MPEG-2 and MPEG-4 or lossless transcode MPEG-2 and remove a cutlist from the program. Since a list of commercial flags is not a cutlist, it is not removed automatically. This document describes how to remove commercials permanently from the source material.
You do not need to do anything on this page if all you are doing is watching recorded shows using Myth TV, then deleting them or letting them auto-expire. You will not save very much space. What the instructions on this page are useful for is if you're storing or archiving your recordings, or are watching your recordings outside of Myth TV.
If you just want to skip commercials from the front end, see Commercial Flagging.
Removing commercials using mythfrontend
You can remove commercials that have been flagged by editing the recording using mythfrontend. Once you have brought up the timeline editor (press E) you can press Z to load the flagged commercials as a cutlist in the editor. Once the cutpoints are created, you can manipulate them normally in the editor to get them exactly where you want them. It is uncommon for the commercial detection to be perfect all the time so some tweaking may be necessary.
After editing is complete, you can choose Begin Transcoding from the OSD menu or you can also choose to Begin Transcoding from the INFO menu in the Watch Recordings screen under Job Options. This will insert a transcode job into the Job Queue which will convert the recording based on your transcode settings in the recording profiles setup.
Removing commercials from the command-line
You must have already flagged commercials for this option to work.
Use mythcommflag to create a cutlist by using
Then use mythtranscode to transcode the recording using the cutlist with
You will need the additional standard options to both programs to choose the proper program based on filename or channel and time. Look at the --help output from each program for details on using these options
Automatically removing commercials
In the 0.20 release of MythTV, you can specify a custom command-line option for both the commercial flagging job and the transcoding job. Using this function, you could create a wrapper script for transcoding after commercial flagging that would use the command-line options outlined above.
chmod 755 /usr/local/bin/removecommercials
Set up a user job that runs the following:
removecommercials %DIR% %FILE%
You can do this by following the directions found on the User Jobs page.
Name the user job "Commercial Removal". You can now remove commercials by highlighting the recording in the recording list, hitting the right arrow, selecting "Job Options", and then selecting "Begin Commercial Removal". You may also set up your recordings to automatically run this script after a recording finishes. For more information on doing this, see the User Manual.
Update All Recordings
If you want to update all your recordings to automatically remove commercials, you could use the following SQL statement:
mysql -u root mythconverg;
or if you have a password on the root mysql account
mysql -u root -p mythconverg;
UPDATE record SET autotranscode = 0, autocommflag = 0, autouserjob1 = 1, autouserjob2 = 0, autouserjob3 = 0, autouserjob4 =0 WHERE autocommflag = 1;
This SQL statement assumes you've set up the job as User Job 1, and will only update those recordings already set to flag commercials.
If it throws an error at the transcoding step check your transcoding prefs. I had to change mine from RJeg to MPEG in the transcoding option in the Recording Prefs.
Also if it gets past the transcoding and then crashes by saying user @ localhost does not have privileges. I had to run backend as root (I don't know how to make my user account have the privileges).
Note from manicmike: An easy way to give the user permissions is to 1) Edit* the sudoers file as root with "visudo" and add the entry <the mythtv user> ALL=NOPASSWD:/usr/local/bin/removecommercials (obviously, change the angle brackets bit to the user running mythtv) then save and quit. 2) change "removecommercials" in your user job to "sudo removecommercials". This will run the job as root while you're still the user.
- in vi, press "i" to go into insert mode. Make the changes and exit using the sequence Esc : x (hit Esc, type a colon, type an x, hit enter).