57

I have a file that ends in .ts, which according to wikipedia is an MPEG2 file. I've never run into a file like this so I want it want the file to be in a more common format/container to use on multiple devices.

4
  • 1
    Old question, but in 2016 with 'normal' Ubuntu codecs, common players like VLC and SMPlayer can play .ts files as such, and maybe they should be left alone, especially that when trying the most voted solution the result was not too good... - I feel the need to rename the extension to mpeg just to get a proper video icon for them.
    – user47206
    Oct 19, 2016 at 12:08
  • @cipricus Post this as an answer and I'll accept it as the new accepted answer. Oct 19, 2016 at 14:32
  • This sort of file we are typically getting when recording directly from a no-name "China" sat-TV decoder unto a USB flash-drive. So this question is relevant in West Africa, when trying to take the file away from the decoder to play on some other device. Sep 7, 2018 at 15:01
  • ts file can be play by VLC media player directly. You also can concat tss to one big ts file with cat *.ts > big.ts(here you may need to use index file m3u8 to get the ts in ordre if the ts name not in order).You also can tranfer them to mp4 with cat *.ts | ffmpeg -i pipe: -c:a copy -c:v copy output.mp4. Refer to my answer here. Aug 6, 2019 at 1:11

7 Answers 7

44

I tend to recommend leaving files in their original state, as any conversion has a chance to introduce loss. The .ts video format is a container format for MPEG, known as "Transport Stream", which is used most frequently by digital broadcasting systems (digital cable, satellite, etc). Many applications are unfamiliar with how to decode it, since it has a very different multiplexing format than the more conventional MPEG container known as "Program Stream", which is what is used on DVDs, and what is produced by many encoder cards. The difference between TS and PS is only how the packet structure is built; the A/V data inside it is the same.

To get better interoperability, I recommend converting the container from TS to PS. Virtually every piece of software that can decode TS can decode PS, so it's almost always better to have PS file. One of the simplest remuxing tools I've found to use is avidemux. Just choose "copy" for the video and audio streams, and choose the "PS" container format for MPEG:

avidemux

Then just save out the result. This can also be done using ffmpeg. You just need to select the copy codec for each stream type:

ffmpeg -i input.ts -vcodec copy -acodec copy output.mpg
1
  • 2
    AFAIKT, converting with that command indeed introduced loss. Keeping the file as is seems the better option as long as there is a player that can play it, and all my players can. Only it lacks a proper icon: and that can be solved by renaming the extension to 'mpeg'.
    – user47206
    Oct 19, 2016 at 12:02
39

.TS files are technically just MPEG2 files. You can use pretty much any converter (avidemux, handbrake or even ffmpeg directly).

But the only reason to do so would be filesize. Mpeg2 files play pretty much everywhere. The only confusing part is the actual file-extension.

You can safely and freely rename them to .mpeg

PS. By turning it into Matroska, you just made is very hard for people on other systems to be able to play the file. I understand picking a free codec, and then choosing the appropiate container, but if you keep it at MPEG2, why change the container to something relatively obscure?

5
  • Thanks for clearing this all up! Renaming it seems to be exactly what I needed to get me video players to recognize the file. Sep 5, 2010 at 17:55
  • 40
    A .ts file is an MPEG ‘transport stream’; it's not at all the same container as a ‘program stream’ (typically .mpeg). Resolution has nothing to do with it. Transport streams can contain multiple independent groups of video/streams, and have a load of error correction data (making .ts files bigger). They're typically used for broadcast systems where multiple channels are multiplexed and the transmission medium may be unreliable. For PC use where file integrity is (hopefully) assured, you will save space and improve compatibility by converting to a Program Stream.
    – bobince
    Sep 6, 2010 at 7:29
  • 26
    This answer is wrong. There are two different container formats for MPEG: MPEG-PS (program stream) and MPEG-TS (transport stream). MPEG-PS files can be .mpeg, .mpg, .vob, etc. MPEG-TS files can be .ts, .mts, or something else. You cannot simply change the file extension to convert between them. But you can re-mux from one to the other without losing quality, retaining the same encoded video/audio streams from one container format to the other. BTW, Ralf's suggestion may appear to work but only in media players that ignore the file extension and support both formats anyway. Nov 7, 2012 at 9:01
  • Kees Cook's answer is the one that I would recommend following. Nov 7, 2012 at 9:05
  • 11
    According to who MKV is "obscure"? Aug 4, 2014 at 11:36
5

From looking at this forums thread I can make it into a matroska file, which I already use.

 ffmpeg -i input.ts -vcodec copy -sameq -acodec copy -f matroska output.ts

I was able to encode this despite this information the seems to indicate that I needed to compile ffmpeg from source. The downside to this is that it doesn't encode the file, so the file is as large as the MPEG2 file. More answers with recommendations for encoding .ts->MPEG4 would help me out.

2
  • 5
    -sameq doesn't do anything when using "copy" as the codec. Also it usually doesn't mean what people think it means - it doesn't preserve the same "quality" for example, but the same "q" factor. Nov 7, 2012 at 9:04
  • 6
    Plus there's no reason for the output file to have a ".ts" extension. "output.mkv" would be more appropriate and less misleading. Nov 7, 2012 at 9:04
3

Actually .ts files are created by DVB-S/DVB-S2 tuners capable of recording transponder streams and can contain mpg2 AC3 AAC h264 mp3, as well as other data ie Teletext or EPG. .ts files contain in most cases just AV data but are not limited to that. VLC can play ts files directly and give You some info about some of the streams in it. Im personally using a sat tuner that records HD channels in .ts files (h264 video and in most cases multiple AAC mp3 mpg2 audio streams). So basically .ts files can contain many different things Its just container format created for sending digital broadcasts over loosy media. VLC can also convert betwen formats (hevent done this myself)

2
  • 1
    Please add details about the conversion process.
    – Anwar
    Oct 20, 2012 at 6:15
  • 1
    The information about TS formats looks all good, it's just that no info is given about the actual conversion process. Nov 7, 2012 at 9:05
1

I usually use HandBrake to convert all kind of video files to iPhone-compatible format. Maybe you can use it to convert the .ts files into MP4. Check this HandBrake PPA to install it.

0

The handling of TransportStream files produced by DVB-S recorders depends on the contained video and audio stream. For material in SD quality it is likely that you can use a tool chain consisting of ProjectX and mplex to convert the stream into a standard MPEG container. If the video stream is HD, try MKVMerge to convert it into an MKV file. Both ways are described in detail this blog post.

-2

The ffmpeg program has been deprecated in favor of avconv.

You can pass the same arguments to avconv to convert from transport stream to program stream mpeg or matroska.

MPEG:

avconv -i input.ts -acodec copy -vcodec copy output.mpg

Matroska:

avconv -i input.ts -acodec copy -vcodec copy output.mkv

2
  • 6
    Out of curiosity, deprecated by whom? Aug 11, 2013 at 21:05
  • 9
    Avconf is a fork of ffmpeg which is still alive and actively developed. Don't believe the FUD that libav.org is spreading. See for yourself: ffmpeg.org and libav.org
    – thom
    Nov 16, 2013 at 14:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .