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.
If you just want to skip commercials from the front end, see Commercial Flagging.
Removing commercials using mythfrontend
The Editor allows you to remove any commercials that the may not have been detected by the system during recording. You might also want to remove the lead in prior to a show or the overrun at the end of a show. The process of editing is often referred to as creating a Cut List. This is because MythTV does not actually cut the Recording. Instead it creates a collection of in and out points in the database that is associated with that recording.
Hit Z to load the current commercial cutlist, if the commercial flagging job had already been run.
The Timeline Editor will now appear. If it's barely visible, you might want to switch the OSD theme to retro, which has a colorful timeline. OSD themes are set separately from the MythTV theme in the Frontend "Playback" setup.
Use to change the amount to move. This varies between 0.5 Secs to 10Mins. You also have the option of 1 frame at a time, 1 keyframe at a time and finally a cutpoint at a time (jumps from cutpoint to cutpoint).
Use to choose between Delete before this point or after this point. Just add the cutpoints that you need. The system will remember these the next time that you bring the recording up. Red areas along the Timeline will be deleted (Skipped). Green areas will be played.
If you now transcode this recording the system will take the Cutlist and produce an edited Recording ready to be exported.
The transcoder re-encodes files from one MythTV format to another. There are two reasons to transcode
- Allow users to create MPEG-4 streams to save space.
- Physically cut the commercials or video segments from the recordings.
Use the Recordings Profiles to change how the system transcodes your recordings
mythfrontend -> utilities/setup -> TV Settings --> recording Profiles -> Transcoders.
now select either RTjpeg or MPEG-4 (selecting any of the hardware encoders will result in the transcoder not working). set the other parameters as you'd like. For best performance, you should match the audio to the 'Default' profile. If you plan to only use the manual transcoder, you can choose to set the video to be the same as the default profile too (as long as it is MPEG-4 or RTjpeg)
The transcoder can be used in two ways:
- Automatically re-encode every file once it has completed recording.
- After marking commercials, the transcoder can be run manually to delete the commercials from the file (thus further saving space).
The two methods are independent. The first is an automatic process that can be enabled/disabled through the setup program; the second is a manual method which must be invoked on each recording individually.
You can transcode a recording that has already been transcoded, for example to cut a further section with no loss in quality provided you are going from and to the same format.
To enable automatic transcoding, do the following: start the setup program under the host-specific settings: set the Transcoder Auto-run checkbox, or in newer versions of the program, you may select automatic transcoding from any of the recording profiles you have set up.
Everything should now be setup properly. If you elected to use the Auto-Run feature, the transcoder will automatically launch after each recording is complete. The transcoder thread runs at a low priority, so it should not impact any critical tasks or other recordings.
If you want to manually transcode a program, simply press while watching a recording and select Transcode (you should have already finished marking all commercials and creating your Cut List with the Recording editor).
Once the transcode is complete, mythbackend will replace the old file with the new as soon as it is no longer in use.
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).