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.
7 Answers
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:
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
-
2AFAIKT, 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'.– user47206Oct 19, 2016 at 12:02
.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?
-
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
-
40A .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.– bobinceSep 6, 2010 at 7:29
-
26This 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
-
-
11
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.
-
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
-
6Plus 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
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)
-
1
-
1The 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
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.
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.
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
-
6
-
9Avconf 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– thomNov 16, 2013 at 14:55
.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 tompeg
just to get a proper video icon for them.ts
file can be play by VLC media player directly. You also can concatts
s to one bigts
file withcat *.ts > big.ts
(here you may need to use index filem3u8
to get thets
in ordre if thets
name not in order).You also can tranfer them to mp4 withcat *.ts | ffmpeg -i pipe: -c:a copy -c:v copy output.mp4
. Refer to my answer here.