Difference between revisions of "Lossless Cut"

From MythTV Official Wiki
Jump to: navigation, search
(Prerequisites)
(Tested several of the features in 0.27, seemed to work fine)
Line 7: Line 7:
 
|S24=yes
 
|S24=yes
 
|S25=yes
 
|S25=yes
|S26=yes}}
+
|S26=yes
 +
|S27=yes}}
 
<BR>
 
<BR>
 
=Features=
 
=Features=

Revision as of 01:26, 13 November 2013

Author R.D. Vaughan (IRC: <IReboot> in #mythtv-users)
Description The Lossless Cut userjobs are used in conjunction with MythTV's commflag and editing UI to create loss less cut mkv video files. Lossless Cut supports multiple video, audio encoding types and subtitles formats.
Supports Version24.png  Version25.png  Version26.png Version27.png 



Features

  • Supports MythTV versions 0.24+fixes and higher
  • Supports NTSC, PAL, SD, HD 720p and 1080i recordings
  • A wide variety of Supported Containers, video and audio encoding types and subtitle formats are available
  • Supports automatic subtitle conversion to SRT or VobSub format, cut and remuxing into the final mkv video. See Mkvmerge supported subtitle formats for a complete list
  • Support for recordings with multiple audio, video and subtitle tracks
  • A Debian PPA is available along with source. The PPA has the benefit of always keeping you up to date with the latest enhancements and bug fixes. The source tarball can be easily downloaded and installed on non-Debian based distros. Check Lossless Cut install from PPA or Lossless Cut install from source for details.
  • Includes a userjob that adjusts commercial flag cut frames to their closest keyframes. Which speeds up manual review of commercial flagged cuts points. See: Keyframe Adjustment of Cut and Skip Lists
  • Supports four types of loss less cuts:
    • Export to MythVideo with grabber enhanced metadata or EPG metadata
    • Cut and Save a mkv video file to a user specified directory
    • In place Cut and Replace a Recording with the lossless cut mkv file
    • Individual files generated for each cut segment. This option is primarily used for Concert and comedy recordings where you want to save the specific segments instead of merge them all togther. A very flexible method to automatically name each segment is enabled with a "segment.cfg" file. See the link above for how-to details.
  • Full integration with the MythTV metadata grabbers including a fall back to EPG metadata when the program cannot be found by the grabbers, using the grabbers as set in MythTV settings including the language code
  • When exported or moved the mkv file is renamed to a customizable format e.g. "Sanctuary - S02E01 - End of Nights (1).mkv"
  • When exported to MythVideo any missing sub directories will be automatically created according to a customizable path and naming convention
  • The MythVideo Video storage group does not have to be on the same backend as the recording backend. Transfer of the cut mkv file is handled by the MythTV backend.
  • A support script provides text bug Reports, automated video sample creation and wiki compatible text for adding Supported Recording Devices or Unsupported Recording Devices table rows
  • Optionally, metadata will be added to the mkv container (title, subtitles, season and episode numbers, program description)
  • A text configuration file provides a convenient method to Customize lossless_cut.cfg
  • The command line and arguments used during each step of loss less cut processing is added to a Log file, generated with every userjob. The log file is automatically deleted if the job successfully completes. This is essential information for problem analysis.
  • Apply a video track positive or negative adjustment in millseconds to the Lossless Cut mkv file with the "-D" command line option


Prerequisites

  • Python 2.6 or 2.7 (identical to the MythTV python requirements)
  • MythTV v0.24 and higher backend installed and functional
  • MythTV python bindings
  • lxml (identical to the MythTV python requirements)
  • MKVToolnix v5.7.x or higher, see: MKVToolNix
  • Mediainfo v0.7.5 or higher, see: Mediainfo
  • Lossless Cut install from PPA or Lossless Cut install from source on any backend (master and/or slave) which will be executing a Lossless Cut userjob
  • The lossless_cut.py script requires read/write access to the directories containing the recorded videos


Installation Instructions

Installing Dependencies

You must use recent version of the MKVToolnix and Mediainfo or Lossless Cut will not work. Lossless Cut is not compatible with earlier versions of "mkvmerge". Even recent distributions such as Ubuntu 12.04 do not come with the required version of MKVToolNix so use the PPA or install from source.
HP-mini on the user list suggested that if you are using older versions of Ubuntu and need to compile MKVToolNix or MediaInfo from source then you need to update your toolchain. This can be done using ubuntu devs toolchain ppa. Here are the PPA packages.

Mediainfo

To add the Mediainfo PPA as a 3rd Party source and install Mediainfo, type the following in a terminal session. You will need root access:

sudo add-apt-repository ppa:shiki/mediainfo
sudo apt-get update
sudo apt-get install mediainfo

For Debian add the Mediainfo PPA as a 3rd Party source and install the deb, by typing the following in a terminal session. You will need root access:
The example below is specific to Debian 7 "Wheezy" but you can change the two instances of "precise" to the Ubuntu distribution that is closest to what your Debian install reflects.

su root
echo "deb http://ppa.launchpad.net/shiki/mediainfo/ubuntu precise main #MediaInfo" >> /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/shiki/mediainfo/ubuntu precise main #MediaInfo Source" >> /etc/apt/sources.list
gpg --keyserver keyserver.ubuntu.com --recv-key 61260473f9d8bc54
gpg -a --export 61260473f9d8bc54 | apt-key add -
apt-get update
apt-get install mediainfo
exit

Mediainfo PPA.Alternately if you cannot or do not want to use a PPA then see: Mediainfo

MKVToolNix

MKVToolNix supports many Linux distributions and multiple releases of those distributions. Installation instructionsand alternately Source downloads
NOTE: You only need to install the "mkvtoolnix" package but NOT the "mkvtoolnix-gui" package.

Lossless Cut install from PPA

NOTE: Ubuntu 11.04 Natty users, it appears that Launchpad will no longer allow adding debs for your installed Ubuntu version. This should not be a problem as you can download the latest deb from later Ubuntu versions (e.g. 12.04) and install it via the command line. The package dependencies have not changed from the original 11.04 deb or is there any 32bit or 64bit dependencies:

sudo dpkg -i "/path to downloaded deb/losslesscut.deb"

Do not install Lossless Cut until you have successfully installed both Mediainfo and MKVToolNix.
The Lossless CutLaunchpad PPA

To add the Lossless Cut PPA as a 3rd Party source and install the deb, type the following in a terminal session. You will need root access:

sudo add-apt-repository ppa:r-d-vaughan/lossless-cut
sudo apt-get update
sudo apt-get install losslesscut

For Debian add the Lossless Cut PPA as a 3rd Party source and install the deb, by typing the following in a terminal session. You will need root access:
The example below is specific to Debian 7 "Wheezy" but as long as you have satisifed the listed dependencies the deb is release/architecture agnostic.

su root
echo "deb http://ppa.launchpad.net/r-d-vaughan/lossless-cut/ubuntu precise main #Lossless Cut scripts" >> /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/r-d-vaughan/lossless-cut/ubuntu precise main #Lossless Cut Source" >> /etc/apt/sources.list
gpg --keyserver keyserver.ubuntu.com --recv-key FEB573EB54BB4483
gpg -a --export FEB573EB54BB4483 | apt-key add -
apt-get update
apt-get install losslesscut
exit

Lossless Cut install from source

Install the entier "lossless_cut" directory anywhere as long as the script has read/write access to the recorded videos directory.
To install Lossless Cut from source:

  • Download the latest tarball from Lossless Cut Source
  • Open the downloaded file and extract the entier "lossless_cut" directory where ever you want. Specifically from the tar ball at
    "/~r-d-vaughan/lossless-cut/trunk/lossless_cut/usr/share/lossless_cut"
  • Ensure the following scripts have execute permissions:
lossless_cut/lossless_cut.py
lossless_cut/keyframe_adjust.py
lossless_cut/ll_report.py
lossless_cut/subtitle/ccextractor32bit
lossless_cut/subtitle/ccextractor64bit

Verify that you are ready to use Lossless Cut

NOTE: DO NOT RUN THIS STEP AS ROOT! A few users did and the permissions of the configuration file and the working directory cause issues when you run Lossless Cut as a userjob. This can be very confusing to analyse.

If you run your MythTV backend under an account like "mythtv" then run the following to avoid permission issues with the workpath and/or configuration file:

sudo -umythtv ./lossless_cut.py -f "/path to a/recorded.mpg" --test

Otherwise run the following command in a terminal session.

./lossless_cut.py -f "/path to a/recorded.mpg" --test

This command will verify that your MythTV backend has all the required prerequisites. Running this test will also automatically create the Lossless Cut configuration file "~/.mythtv/lossless_cut.cfg" or added new sections to a pre-existing cfg file.

If you see the "Congratulations!" message at the bottom of the default settings display you are good to go:

Congratulations! All script dependencies have been satisfied.
You are ready to perform loss less cuts on MythTV recorded videos.

Customize lossless_cut.cfg

NOTE: It seems a number of users are neglecting to examine the "~/.mythtv/lossless_cut.cfg" file. This file can save you using command line arguments as most of them can be set directly in the cfg file. Also the target directory location format for MythVideo export and filename format for moving and exporting are highly configurable. I encourage any user to at least view the options contained in the cfg file.

Assuming you successfully verified that Lossless Cut will run on your installation you should review and alter as required the configuration file "~/.mythtv/lossless_cut.cfg" with a text editor. There is nothing wrong with just using the default configuration. The configuration file contains extensive documentation.

MythTV User Jobs

Add two or three user jobs to MythTV. See: Adding a User Job

Keyframe Adjustment of Cut and Skip Lists

This user job is optional but will help speed up setting accurate cut points after you have commflagged a recording. When you schedule a recording or create a recording rule, enable auto flag commercials and this Keyframe Adjust user job.
If you installed Lossless Cut from the PPA:

User Job description: Keyframe Adjust
User Job command: /usr/bin/keyframe_adjust -f "%DIR%/%FILE%"

If you installed Lossless Cut from source:

User Job description: Keyframe Adjust
User Job command: /path to script/keyframe_adjust.py -f "%DIR%/%FILE%"

When this job runs every skip or cut frame will be adjusted to its nearest keyframe according to the recorded file's seek frames.

  • The start cut frames are adjusted to the nearest keyframe less than or equal to the start skip or cut frame number
  • The end cut frames are adjusted to the nearest keyframe greater than or equal to the end skip or cut frame number

To have a cutlist automatically generated when there is a skip list add the "-g" command line option to the User Job Command, for example:

User Job command: /usr/bin/keyframe_adjust -f "%DIR%/%FILE%" -g

Loss Less Cut user jobs

There are three different options for Lossless Cut user Jobs. The first two are non-destructive, which means that the original recorded video is left untouched.
NOTE: The "-D" delay option changes when the video track starts playing by a positive or negative number of milliseconds. When your recording already has audio and subtitle track(s) with a delay then the delay you specify with the "-D" option does not replace the delay in your recorded file. It will add or subtracted from what is already there. For example if your recoding's audio track has a delay of 3ms and you specify "-D -300" then that audio track will end up with a delay of "-297ms" before it starts in the Lossless Cut mkv file. This is just how mkvmerge works. In general this option should rarely be used. This option will not correct a Lossless Cut video that exhibits audio drift overtime.

Export to MythVideo

If you installed Lossless Cut from the PPA:

User Job description: LL Cut to MythVideo
User Job command: /usr/bin/lossless_cut -f "%DIR%/%FILE%" -e

If you installed Lossless Cut from source:

User Job description: LL Cut to MythVideo
User Job command: /path to script/lossless_cut.py -f "%DIR%/%FILE%" -e

Cut and Save

If you installed Lossless Cut from the PPA:

User Job description: LL Cut and Save
User Job command: /usr/bin/lossless_cut -f "%DIR%/%FILE%" -m "/path to save cut mkv video file"

If you installed Lossless Cut from source:

User Job description: LL Cut and Save
User Job command: /path to script/lossless_cut.py -f "%DIR%/%FILE%" -m "/path to save cut mkv video file"

NOTE: Lossless Cut requires read/write access to the "-m" directory path.

Cut and Replace a Recording

Be warned: After the successful creation of the mkv file the old recording will be replaced in the "Watched Recordings" screen and the original mpg file will be deleted. Any cut and/or skip list will be removed. The MKV file will have the same name as the original recording but with a "mkv" file extension.
If you installed Lossless Cut from the PPA:

User Job description: LL Cut & Replace
User Job command: /usr/bin/lossless_cut -f "%DIR%/%FILE%" -r

If you installed Lossless Cut from source:

User Job description: LL Cut & Replace
User Job command: /path to script/lossless_cut.py -f "%DIR%/%FILE%" -r

Lossless Cut Work Flow

  • Assume that you enable the auto commercial detect user job then run/enable the Keyframe Adjust user job
  • For the best lossless cut results use the "Edit the Recording" instructionsand always set your cut points to keyframes
  • After saving the cuts run one of the three Loss Less Cut user jobs
  • Watch the cut video. Assuming you did not replace the original recording you can always go back and fine tune your cuts as described in the previous step. Remember to delete the previous exported or saved cut video file before running the Lossless Cut job again.
  • Assuming you did not replace the original recording and you are satisfied with the cuts delete the original recording

NOTE: If you perform a second cut and "-m" move but had NOT deleted the previous cut video, a second video file will be created with a date and time tagged on to the end of the file name. In this way you can never accidentally overwrite an existing file with the same name.
E.g. "Boss (2011) - S02E02 - Mania - Thur Sep 20th 12:00:02.mkv
A second cut on a MythVideo "-e" exported video will fail. You need to use the MythVideo UI to delete the video. This cleans up both the video file and the MythVideo database record.

Concert Cuts

When specified this option creates individual mkv files from each segment specified in the cut list. The Concert Cuts option is not intended to be used as a userjob but should be run from a terminal session. This is a powerful option for creating music tracks from a Concert recording or saving your favourite comedy skits from a show like SNL (Saturday Night Live).
This option must be accompanied by either a "-m" move or "-e" export option. Replacing "-r" is not valid.
You can specify a naming format and/or individually name each track including the subdirectories to save the segment files by creating a "segment.cfg" file before you run this Lossless Cut option. See details below. Any missing subdirectories are automatically created either when exporting to MythVideo or moving the cut segments to a directory.

Concert Cuts Workflow

  • Generate the cut segments through the MythTV edit UI
  • Copy the "example_segment.cfg" file and rename it to something relevant to the recording (e.g. /tmp/Seether_One_Cold_Night.cfg). You will likely only use this file once. The example file is located in the "lossless_cut/importcode/example_segments.cfg" subdirectory. If you installed via the PPA it would be located in "/usr/share/lossless_cut/importcode/example_segments.cfg"
  • Use a text editor to specify the naming format for all of the segments or specific segment file names or a mixture of both. The ability to name individual tracks can be a powerful tool for a Concert recordings where multiple artist performed and you want to properly identify each artist, album, song and even specifically where to save the segment. The "example_segment.cfg" file contains extensive documentation on all if these options.
  • Run the Concert cuts from a terminal session on the MythTV backend where the recording resides
lossless_cut -f "/path to/recordingfile.mpg" -C "/path to segment cfg file/Seether_One_Cold_Night.cfg" -e

Additional Concert Cut options

Strip out all but one audio track. The resulting video file can still be played by the MythTV internal player but the screen will display all black. The very first audio track will be used.

lossless_cut -f "/path to/recordingfile.mpg" -C "/path to segment cfg file/Seether_One_Cold_Night.cfg" -S -e

Strip out all but a specific audio track. If you have multiple audio tracks and the one you want to use is not the first one then do these two steps:

  • Display the audio track order and note which one you want to use:
mediainfo "/path to/recordedfile.mpg"
  • Concert Cut the recording but select the specific audio track to include with the "-T" option
lossless_cut -f "/path to/recordedfile.mpg" -C "/path to segment cfg file/Seether_One_Cold_Night.cfg" -S -T 2 -e

Transcode the audio into a encoding compatible with regular music players including MythMusic. For this example you would need to install ffmpeg. This is just an example as there are multiple tools you can use to extract and re-encode or copy the audio track from the mkv file.

ffmpeg -i "/path to concert cut file/01 - Seether: One Cold Night - Broken.mkv" -acodec flac -ac 2 -aq 100 -ar 48000 -f flac -y "/path to my music collection/01 - Seether: One Cold Night - Broken.flac"

DVB Subtitles

DVB Subtitles are supported with the ProjectX v0.91.0 java applet. Although this recent version of ProjectX is included with the Lossless Cut PPA and source the required Java runtime is not. Some users may not want Java installed or need DVB Subtitle support. If you want to have DVB Subtitle support follow these three simple steps:

  • Install either the open or Sun Java runtimes for example with a Debian distro use one of the following commands:
sudo apt-get install libcommons-net-java default-jre

OR for the Sun Java runtime:

sudo apt-get install java2-runtime
  • Automatically add the DVB Subtitle section to your "~/.mythtv/lossless_cut.cfg" file by rerun the environment test again, see: Verify that you are ready to use Lossless Cut
  • Edit your "~/.mythtv/lossless_cut.cfg" file and change the following configuration variable from "false" to true":
include_dvb_subtitles=true

Optionally modify any of the other variables in the "dvb_subtitles" configuration section.

Auto Remove Recording

Sometimes you may want to export or move recordings and have their original recordings automatically deleted. These would be recordings with no skip or cut lists, recordings you consider low risk or generally do not care if they are not Lossless Cut accurately. For those type of recordings you can specify configuration rules to have them deleted after a successful export or move.

  • Automatically add the "remove_recorded" section to your "~/.mythtv/lossless_cut.cfg" file by rerun the environment test again, see: Verify that you are ready to use Lossless Cut
  • Edit your "~/.mythtv/lossless_cut.cfg" file and read the ample documentation in the "remove_recorded" section to add rules for which recordings should be automatically deleted


Customize the mkvmerge cut and merge command line

A new section called "mkvmerge_user_settings" has been added to the "~/.mythtv/lossless_cut.cfg" file.

  • Automatically add the mkvmerge_user_settings section to your existing "~/.mythtv/lossless_cut.cfg" file by rerun the environment test again, see: Verify that you are ready to use Lossless Cut
  • Edit your "~/.mythtv/lossless_cut.cfg" file and read the ample documentation in the "mkvmerge_user_settings" section to add your own mkvmerge command line options

The two variables in this section allow you to add custom options to either/or the mkvmerge cut or merge processing. You need to understand the mkvmerge options to use these variables effectively and not mess up the Lossless Cut processing.

One person uses these variables to override a mkvmerge default action. Mkvmerge sets Audio Track 1 as the default audio track. This switch stops it setting any track as default. The player (mythtv in this case) then sets the audio track based on its own logic. Here is that setting as it should appear in the lossless_cut.cfg file:

mkvmerge_merge_addon=--default-track -1:0

In general it is unlikely that you will need to add your own variables but just in case here is a link to the mkvmerge CLI documentation.

User Specified Error Detection

A new section called "error_detection" has been added to the "~/.mythtv/lossless_cut.cfg" file.
The vast majority of users will never need to touch these configuration variables.

  • Automatically add the error_detection section to your existing "~/.mythtv/lossless_cut.cfg" file by rerun the environment test again, see: Verify that you are ready to use Lossless Cut. By default none of the variables are enabled.
  • If you enable the configuration variables in this section you MUST add -j "%JOBID%" to your Lossless Cut userjob command line. For example:
User Job description: LL Cut to MythVideo
User Job command: /usr/bin/lossless_cut -f "%DIR%/%FILE%" -e -j %JOBID%
  • Edit your "~/.mythtv/lossless_cut.cfg" file and read the ample documentation in the "error_detection" section to add your own command(s) to detect problems with lossless cut processing

Here is an example scenario for the "error_detection" variables:
Your userjob specifies the "-r" replace option but occasionally has recordings which mkvmerge detects as having GOP errors. Most of the time the resulting lossless cut MKV file is useless. You want to be warned when a specific number of GOP errors have been detected but still would like to try the MKV file. When the GOP errors are excessive you do not want to have the MKV created. In both cases you do NOT want the original recording replaced.
To cover this situation you would need two configuration variables.

error_detection_01=alert, 30, cat "%(logfile)s" | grep -c "GOP", %(error_cnt)s GOP errors detected
error_detection_02=abort, 99, cat "%(logfile)s" | grep -c "GOP", Excessive number "%(error_cnt)s" of GOP errors

Reports

As it is very difficult to anticipate all the issues that may occur while processing recordings produced by the wide variety of MythTV devices. This is the reason that the bug reporting script ll_report.py has been included. There are four variations of reports that can be produced.

  • Create a text file report that includes detailed information about the OS, the relevant utility versions in your environment, the recording device used and the specifics of the recorded video file (fps, resolutions, etc ...).
    See: Bug Reporting Option: -b
  • Create an archive of the text file mentioned above, the associated log file plus a 25Mg video file containing the first ~30 seconds of the recorded video file. The archive (tar.bz2) should be uploaded to an Internet location or service like mediafire or dropbox so that the developer can download and analyze the issues.
    See: Bug Reporting Option: -B
  • Create an archive of the text file mentioned above, the associated log file plus a 25Mg video file containing ~30 seconds starting at a specific start time into the the recorded video file. The time is expressed in "HH:MM:SS" format. The "HH" and "MM" are optional. The archive (tar.bz2) should be uploaded to an Internet location or service like mediafire or dropbox so that the developer can download and analyze the issues.
    See: Bug Reporting Option: -B -s HH:MM:SS
  • Display text lines which can be cut and pasted into this Wiki's Supported Recording Devices or Unsupported Recording Devices recording device table. That text lines contains information about the device which recorded the video plus track details.
    See: Wiki Table Row Generation Option: -w

Bug Reporting

If you have a problem to report please take the time to report the issue by following these steps.

  • Run the Lossless Cut script as it appears in your User Job but with an additional -k option. This will ensure that the log file is not deleted. For example:
lossless_cut -f "/path to the problem/recordedfile.mpg" -e -k

If the problem does not require a sample video file then:

  • Run the bug reporting script for example:
ll_report -f "/path to the problem/recordedfile.mpg" -b
  • Copy the text bug report to your clipboard
  • Post on the MythTV usermailing list a description of the problem and paste the text bug report into that email

If the problem requires a sample video file then:

  • Run the bug reporting script for example:
ll_report -f "/path to the problem/recordedfile.mpg" -B
  • Upload the resulting archive file to a service like mediafire or dropbox
  • Post on the MythTV usermailing list a brief description of the problem and include the URL of the bug archive

Wiki Table Row Generation

ll_report -f "/path to a/recordedfile.mpg" -w
  • Copy to your clipboard the text which looks like:
|-
|Manufacturer
|Model
|DVB-T
|MPEG Video Version 2
|MPEG Audio Version 1 Layer 2 codec-3
|Teletext, DVB Subtitle codec-6
  • Log on to the MythTV wiki
  • Navigate to this wiki page, click "edit" on the appropriate section containing the table which you want to add a row
  • Paste the copied text into the table making sure the Manufacturer name will maintain row alphabetic order
  • Change the "Manufacturer" and "Model" test to your specific recording device
  • Preview your changes by clicking the "Show Preview" button
  • When you are satisfied with the new row, save the changes by clicking the "Save page" button

Supported Containers, video and audio encoding types and subtitle formats

Despite the formats MKVToolNIX supports, Lossless Cut can only accurately cut a recording which has valid keyframe seek records in the MythTV database. This means it is unlikely that videos which are manually added to MythTV will produce quality results.

How to check what your install supports

You can check what your version of MKVToolNix supports by typing the following in a terminal session:

mkvmerge -l

The containers, video, audio encoding and subtitle formats listed below are specific to "mkvmerge v5.8.0 ('No Sleep / Pillow') built on Sep 2 2012 14:35:40". Use the command above to see what your installed version supports. New capabilities are always being added to MKVToolNix.

Recorded Video Input Containers

Note: All Lossless Cut videos will be output in a MKV container.

  • Matroska audio/video files [mka mks mkv mk3d webm webmv webma]
  • QuickTime audio/video files [mov]
  • Ogg/OGM audio/video files [ogg ogm ogv]
  • RealMedia audio/video files [ra ram rm rmvb rv]
  • AVI (Audio/Video Interleaved) [avi]
  • WebM audio/video files [webm webmv webma]

Video Input encoding

  • AVC/h.264 elementary streams [264 avc h264 x264]
  • Dirac [drc]
  • IVF with VP8 video files [ivf]
  • MP4 audio/video files [mp4 m4v]
  • MPEG program streams [mpg mpeg m2v mpv evo evob vob]
  • MPEG transport streams [ts m2ts mts]
  • MPEG video elementary streams [m1v m2v mpv]
  • VC1 elementary streams [vc1]

Audio Input encoding

  • A/52 (aka AC3) [ac3 eac3]
  • AAC (Advanced Audio Coding) [aac m4a mp4]
  • ALAC (Apple Lossless Audio Codec) [caf m4a mp4]
  • Dolby TrueHD [thd thd+ac3 truehd true-hd]
  • DTS/DTS-HD (Digital Theater System) [dts dtshd dts-hd]
  • FLAC (Free Lossless Audio Codec) [flac ogg]
  • MPEG audio files [mp2 mp3]
  • TTA (The lossless True Audio codec) [tta]
  • WAVE (uncompressed PCM audio) [wav]
  • WAVPACK v4 audio [wv]

Subtitle Input Formats

NOTE: As of v0.1.5 Lossless Cut supports the extraction of DVB Subtitles and teletext format subtitles. Neither or these subtitle formats are supported directly by mkvmerge but Lossless Cut uses the following included utilities:

  • With mythccextractor (MythTV v0.25 and higher) and/or CCExtractor v0.64-alpha7, teletext subtitles are extracted and converted to SRT then muxed back into the MKV file
  • ProjectX v0.91.0 extracts DVB Subtitle tracks and converts them into idx/sub files which are muxed into the MKV file as a VobSub. See DVB Subtitles for details.


The subtitle tracks that mkvmerge supports natively:

  • PGS/SUP subtitles [sup]
  • SRT text subtitles [srt]
  • SSA/ASS text subtitles [ass ssa]
  • USF text subtitles [usf xml]
  • VobSub subtitles [idx]

Current list of MediaInfo supported formats

MediaInfo is used to identify what tracks (Video, Audio and Subtitles) are included in a MythTV recording. This information is used during Lossless Cut processing. See: Supported Formats

Supported Recording Devices

Please add your table row in "Manufacturer" and "Model" alphabetical order. Before adding your device to this table please check that it is not already listed.

Manufacturer Model Recording Device Video Codec(s) Audio Codec(s) Subtitle Formats(s)
UK FreeView SD Channels (MPEG2)1 DVB-T (UK) MPEG Video Version 2 MPEG Audio Version 1 Layer 2 codec-3 Teletext, DVB Subtitle codec-6
UK FreeSat SD (MPEG2) Channels1 DVB-S (UK) MPEG Video Version 2 MPEG Audio Version 1 Layer 2 codec-3 Teletext, DVB Subtitle codec-6
UK FreeSat HD (h.264) Channels1 DVB-S2 (UK) AVC Version 2 AC-3 Layer 2 codec-129, MPEG Audio Version 1 Layer 2 codec-4 DVB Subtitle codec-6, Teletext Subtitle
Hauppauge Nova-T 500 Dual DVB-T DVB-T (Mediaworks NZ) AVC Version 2 AAC HE-AAC / LC codec-17, AC-3 codec-129L DVB Subtitle codec-6S
Hauppauge Nova-T 500 Dual DVB-T DVB-T (TVNZ NZ) AVC [AAC Version 4 LC codec-15], AAC HE-AAC / LC codec-17, AC-3 codec-129LO [Teletext], DVB Subtitle codec-6O
Hauppauge 1212 HDPVR AVC AC-3 codec-129
Turbosat TBS 6981 DVB-S2 (UK) AVC AC-3 codec-129D, MPEG Audio Version 1 Layer 2 codec-3 Teletext SubtitleT, DVB Subtitle codec-6
Turbosat TBS 6981 DVB-S (UK) MPEG Video Version 2 MPEG Audio Version 1 Layer 2 codec-4 TeletextT, Teletext SubtitleT, DVB Subtitle codec-6
Turbosat TBS 6981 DVB-S2 (NL) AVC AC-3 codec-129 TeletextT
Turbosat TBS 6981 DVB-S (NL) MPEG Video Version 2 MPEG Audio Version 1 Layer 2 codec-4 TeletextT

  • 1 - The convention in the UK is for SD channels to be MPEG2 encoded, and HD channels to be h.264 encoded (and for all channels on DVB-T/DVB-S to be MPEG2). The entries in this table relate to the video encoding standard, and the SD/HD indicator is just a guide based on UK convention.
  • T - Teletext Subtitles present and display in mythtv
  • D - Default Audio order tagging Lost. ( UK channels play Audio Description Track after lossless cut, need to select AC3 or main track manualy) Adding "mkvmerge_merge_addon=--default-track -1:0" to lossless_cut.cfg will work round this mkvmerge feature.
  • L - LATM removed by remuxing original ts file.
  • O - [options] these 2 options seem to be mutual exclusive.
  • S - Had to remove dvb-subs to be able to LATM remuxL.

Unsupported Recording Devices

Please add your table row in "Manufacturer" and "Model" alphabetical order.
Before adding your device to this table please post a bug report to the MythTV mailing list. Follow the Bug Reporting instructions. Also if the script works, most of the time, with the recordings from a particular device then it is likely that the recording itself is the issue. See the first bullet of Known Limitations. Only post a table row for an Unsupported device when Lossless Cut consistently fails.

Manufacturer Model Recording Device Video Codec(s) Audio Codec(s) Subtitle Formats(s)
Hauppauge Nova-T Stick(1) UK DVB-T MPEG Video Version 2 MPEG Audio Version 1 Layer 2 codec-4 DVB Subtitle codec-6

  • "1" - User Job completes. However subtitles are not processed, and the resultant MKV has significant frame drops (incomplete GOP reports from mkvmerge.)

Known Limitations

  • If the original recording is corrupted then Lossless Cut is unlikely to work. Audio sync and faulty edits have been observed. Likely these type of recordings would suffer the same fate when edited in video editors like Avidemux. MythTV can often play back the original recordings and pass through the area(s) of corruption but you will notice that is where Lossless Cut video runs into problems.
  • As of Jan 3rd, 2013 this issue may be fixed, see: Commits for MythTV v0.25+fixes and higher
    Specifically for h.264 encoded videos, any rebuild of the recording's seektable (mythcommflag --rebuild or --video) does not produce valid keyframes. This means that the Lossless Cut script will not likely cut a video accurately even when setting the keyframe cut points manually with the frontend edit UI. The lossless cut results are a hit and miss proposition, which will not change until ticket #11144is fixed. Most of the time this limitation will not effect anyone unless you try to manually add a recording to MythTV and then rebuilding the seek table. Restoring the original seek records from a database backup will work as the keyframes would be accurate. Unless you know what you are doing it is not recommended that you replace/restore specific records in a database.
  • As of Jan 3rd, 2013 this issue may be fixed, see: Commits for MythTV v0.25+fixes and higher.You can force mythtccextractor to be use by adding "-X or --forcemythxxextractor" as a command line paramater to a Lossless Cut user job
    mythccextractor will not be used until ticket #11081is fixed. Currently CCExtractor (included with Lossless Cut) is exclusively used for subtitle extraction and conversion to SRT format.
  • Recorded videos without MythTV seek table records cannot be edited
  • Recorded videos that have been replaced by a loss less cut mkv video cannot be re-edited
  • The way the HDHomerun recording device works is not always compatible with mkvmerge and therefore Lossless Cuts are hit and miss. See this issue example:
    • A user has reported that Lossless Cut works as expected with their HDHomerun device for all but a few specific channels (e.g. ABC channel 13 WZZM in Grand Rapids). Lossless Cut videos from that channel produces only an audio track. While on a different channel (NBC Grand Rapids) the merge of cuts segments consistently excludes the very last cut segement. More than one user has noted inconsistencies in how mkvmerge treats HDHomerun recordings. Hopefully MKVToolNix future releases will address these issues.

Credits

  • The developers at Bunkus.orgfor the MKVToolNix suite of utilities. Without those utilities Lossless Cut would not exist.
  • The MediaInfodevelopers
  • Ian Thiele for his h264cut.sh scriptwhich demonstrated the versatility and maturity of the MKVToolNix "mkvmerge" utility. Also Lossless Cut follows the same general process flow for video cut and merging as in his h264cut.sh script.
  • Raymond Wagner for developing the Python bindings including adding new bindings when requested. Also for putting up with my questions on how to use the python bindings to their best effect.
  • Carlos Fernandez for his versatile subtitle extractor utility CCExtractorand his excellent support
  • Scott Harris for supplying multiple bug sample archives and for doing bug fix testing
  • Andy Boff for providing a sample of UK DVB-T recording which included multiple audio tracks and subtitles tracks