Editing HD TS files and converting TS to XviD, MKV, 720p, etc



Cutting out ad-breaks and other unwanted content

While having ad-breaks and extra content at the start of a recording can be inconvenient, it also takes up a significant amount of disk space. For example, three 5 minute ad-breaks with a little excess recording before the show on a HD channel can easily take up 2GB of space! This wasted space can be recovered by cutting out this unnecessary content.

TS Cutter is a very useful freeware editor for cutting out unwanted content out of TS HD recordings, as it can cut out the ad-breaks and rejoin the parts together into a single file again. The following is a simple guide to using it to edit out excess content at the start/end of a recording as well as any ad-breaks.

[li]Launch TS Cutter, go into the File menu, select “Load H.264-TS” and open the TS recording to edit.[/li]

[li]Use the slider to select the beginning of the recording/section to keep. [/li][li]Use the frame navigation buttons (with “<<”, “>>”, etc. symbols) for better accuracy in selecting the start point.[/li][li]Click the “Start” button[/li][li]Use the slider to select the end of the part to keep, such as at the beginning of the first ad-break or the end of the programme if it has no ad-breaks. The frame navigation buttons can be used for better accuracy.[/li][li]Click the “End” button and click “Add”.[/li][li]Repeat steps 2 to 6 for each part of the recording in sequence, so you end up with all parts of the recording you wish to keep in the bottom field.[/li][li]Go into the “File” menu, select “Cut”, specify an output file name and click ‘Save’.[/li][li]Test the edited recording on your preferred media player or set-top box to ensure it plays successfully, especially at the points where the ad-breaks would have been.[/li][/ol]
If the edited recording does not play properly from part to part (e.g. playback stops or crashes where an ad-break would have been), try going into the Option menu in TS Cutter, select “Settings” and set “CutOut only on IDR frame”. Then cut the video again and try the edit this time to see if there is any playback issue this time.

Compressing a TS recording to XviD HD, MKV, etc.

As HD channels generally use a fairly high constant bit-rate regardless of whether they are showing a still image or heavy action, recordings can be significantly compressed with very little effect on the image quality. With some HD set-top players that are not compatible with TS files, the H.264 codec or are limited to 720p only, it is necessary to re-encode recordings to be able to play them.

Unfortunately, there are very few freeware conversion utilities at this time of writing that will directly convert transport streams (especially with H.264 video) to the desired format. For example, one popular process up until recently involved demuxing the audio & video streams, converting them individually to the desired formats, muxing them again and finally syncing the audio with the video.

Probably the best freeware tool that automates the whole encoding process is AutoMKV, which takes a transport stream as its input, lets the user choose the desired encoding formats and options and then automatically carries out all the steps to leave the user with the encoded MKV,AVI, MP4, etc.

Using AutoMKV to encode TS to AVI, MKV, (with MP4, XviD HD), etc.

First, download the latest version of AutoMKV. Note that AutoMKV is dependent on several other applications, such as a recent build of AviSynth, FFdshow, .net Framework, etc. to be installed for it to work properly, so if a conversion process fails or the application fails to start properly, try checking for missing dependencies.

Note that the full AutoMKV package is over 20MB in size at this time of writing. If you end up with a small package (e.g. <1MB) or AutoMKV stops responding and gets stuck at “Loading profiles…”, then it is likely that you have downloaded just an update for AutoMKV and not the complete package.

[li]Start AutoMKV, select the Input file and let it run for a few minutes to analyse the source.[/li]

[li]Select the desired audio format and channels for the audio sound track. Most set-top boxes will handle MP3, AC3 and AAC. For a stereo MP3 soundtrack, choose “Lame”. Then choose the quality or bit-rate. Choose a bitrate of least 192kbps for stereo or 384kbps for 5.1 audio when sound quality is important (e.g. for a live music). [/li][li]Choose the desired video codec. Most network media players will handle XviD. If you have or plan getting a network media player with H.264 support, choose the “X264” option for improved compression and image quality. Note that X264 encoding takes significantly longer to encode than XviD.[/li][li]Choose the desired container. Most network media players handle AVI. If you have or plan getting one that handles MKV, choose this container format if you need improved flexibility in the encoding options. For example, the AVI container does not support a variable bitrate audio track.[/li][li]If the player has a 720p limit on video content, enter “1280” into this field, otherwise leave it as “Automatic”. To down-convert this video to standard definition, choose ‘720’ for this field. [/li][li]If the encoding will be placed on a DVD, choose the disc size from the “Disk Settings” drop-down field. Otherwise, set this to “Don’t care about size” if the encoding will only be stored on a hard disk, e.g. for a set-top media player.[/li][li]Click the “Advanced Settings” tab:[/li]

[li]As HD broadcasts are interlaced, choose “Progressive” for the deinterlacer. If this is set to “Auto”, on occasion AutoMKV will falsely detect the source as progressive video, which would result in a bad encoding with heavy motion artefacts. [/li][li]Set the “Specify AR Input” field to “1.777778” for a 16:9 source. Most HD broadcasts are 16:9, but with many 1080 line broadcasts using a 1440 pixel screen width (e.g. BBC HD), AutoMKV usually tries encoding the video with a 4:3 aspect ratio, which will result in a vertically stretched picture when played with some players.[/li][li]If the “Don’t care about size” option has been chosen for step 5, tick the “Specify Quality” field and select a value. Generally “75” is a good balance between file size and image quality as well as a good value to start off with. If you find that the encoding has noticeable artefacts or the encoded file size is rather excessive, try increasing the figure for improved encoding quality (but with a larger file size) or decreasing this value to a reduced encoding size (but sacrificing on video quality).[/li][li]Finally go back to the “Basic Settings”, choose an output folder (preferably separate to the input) and click “Start Encoding”[/li][/ol]
Once the encoding completes, check the picture and sound quality. If this will be played on a set-top media player, check to make sure it plays back properly and to your satisfaction, especially if you plan deleting the original transport stream file.


Since the time I posted the above conversion process, it seems like the BBC made some changes to its transport stream of BBC HD that breaks video encoders, at least with the TS file recordings DVBViewer produces. I have a feeling it’s a change BBC made, as recordings from Luxe HD still re-encode fine. I haven’t tried recordings from any other HD channel yet.

For example, if I try to use the above process with a BBC HD recording TS file from DVBViewer, I now end up with choppy video. The original command-line method I used involving mencoder no longer works. Other freeware transcoders such as WinFF and Avidemux 2.5 also result in choppy or broken video. Pretty much every commerical encoder I tried also results in problems, e.g. wrong fields being interlaced with Corel VideoStudio, wrong video speed in DVDFab, AV sync issues in TMPGEnc, etc.

After various experiments with various freeware encoding utilities, I finally encountered one successful way of re-encoding the video. The catch is that it involves a buggy alpha release of Avidemux 2.6 and two encoding stages, as Avidemux 2.6 is the only utility I’ve come across that properly handles these TS files.

If you really need to be able to convert a BBC HD TS file to another format, such as for a set-top player that can’t play TS or AVC/H264 video, here’s the process that current works for me, at least for BBC HD recordings made by DVBViewer:

You’ll need the following software (all freeware):

[li]Avidemux 2.6 alpha base & SVN builds (here)[/li][li]7-zip to extract the 7z archives (here)[/li][li]Avidemux 2.5 (here) or your preferred video encoding tool.[/li][/ol]

What we basically want to do is convert the video in the TS file to another format, so that it can be converted to your preferred format using Avidemux 2.5 or another encoder. At this time fo writing, Avidemux 2.6 alpha has very few encoding formats and does not even include a deinterlace filter. Simply copying or raw-dumping the video stream into another file format does not work either, as the problem is in the H264 video encoding itself. Also, with regular SVN updates, this process may break later on. I tested this using build r5537.

[li]Use 7-zip to extract the Avidemux 2.6 base file into a folder. Then extract the SVN file into that same folder, replacing any existing files.[/li][li]Start the file “avidemux3_qt4” (double-click it) to launch Avidemux 2.6 alpha.[/li][li]Open the TS recording.[/li][li]If you have a huge hard disk with ~120GB of free space per hour of video, select “(FF)HuffUV” for the video-drop down and skip the next two steps. [/li][li]For the Video-drop down, select “Mpeg4 ASP (ff)”. [/li][li]Click “Configure”, set the Quantizer to 2 and click ‘OK’.[/li][li]Ensure the “Audio” drop-down is set to “Copy” and “Format” drop-down is set to “AVI”. At this time of writing, only the “AVI” output format works in this alpha release.[/li][li]Click the “Save” icon and specify a name for this temporary encoding.[/li][/ol]

If you select the HuffUV format for step 4, this gives a lossless and quicker encoding for this first stage, which will also result in better quality and faster encoding for the next encoding stage.

Now use your preferred video encoder (e.g. Avidemux 2.5, WinFF, etc.) to encode the resulting file into your preferred video format. Note that some encoders will detect this with the wrong aspect ratio or as progressive video, so if you can manually specify the options, be sure to set the aspect ratio as “16:9” (or 1.78) and to deinterlace the video. Once the conversion is complete, you can delete this temporary video file.

Here’s the process I use in Avidemux 2.5 to convert the video to 720p XviD HD with 192kbps MP3 audio:

[li]Click ‘Open’ and select the video encoding created from Avidemux 2.6 alpha.[/li][li]For the Video drop-down, select “MPEG-4 ASP (Xvid)”[/li][li]Click the “Configure” button and set the quantiser to ‘4’ (my preferred balance between quality & size.)[/li][li]Tick “Predefined Aspect Ratio” and select “64:45 (PAL 16:9)”[/li][li]In the “Motion” tab, set both drop-downs to “Medium” (slower encoding, but better quality.)[/li][li]In the “Frame” tab, set Max Consecutive B-frames to 1 or 2 and “Packed Bitstream”. One of my media players gives choppy video if not using packed bitstream with 2 B-frames.[/li][li]Click ‘OK’ then click the ‘Filters’ button.[/li][li]Go into “Interlacing” on the left and double-click the “Deinterlace” filter. I use the default requested vaules.[/li][li]Go into “Transform” on the left and double-click “MPlayer resize”.[/li][li]Remove “Lock Aspect Ratio” tick and set the width to “1280” and height to “720”[/li][li]For the resize method drop-down, select “Bicubic”.[/li][li]Click ‘OK’, then ‘Close’.[/li][li]For the “Audio” drop-down, select “MP3 (lame)”, then click ‘Configure’.[/li][li]Set the Bitrate to 192 and click ‘OK’.[/li][li]Ensure the format is “AVI” and click ‘Save’.[/li][/ol]

After the video encodes, check a few places to ensure the audio and video are in sync. :slight_smile:

I have re-opened this thread.

[B]Note: [/B]With the large number of spammers posting their conversion “guides” everywhere to advertise their software, any such suspect posts made here will be [U]deleted[/U].