what is difference between mp4 and mpegts?

vinit sharma picture vinit sharma · Aug 1, 2012 · Viewed 47.2k times · Source

Recently I had a task to convert the file format to mp4 and stream it. I have used ffmpeg as the transcoding tool. The MP4 file doesn't get streamed over the http protocol [have used php cgi wrapper], but then the output format is changed to mpegts the streaming occurs and works fine. A quick search on net http://wiki.videolan.org/MPEG relates and advises to use mpegts for streaming mp4 file. I need more insight on these two formats, their advantages and differences.

Thanks, Peter

Answer

Yavor Atov picture Yavor Atov · Aug 3, 2012

MPEG-TS is designed for live streaming of events over DVB, UDP multicast, but also over HTTP. It divides the stream in elementary streams, which are segmented in small chunks. System information is sent at regular intervals, so the receiver can start playing the stream any time.

MPEG-TS isn't good for streaming files, because it doesn't provide info about the duration of the movie or song, as well as the points you can seek to.

There are some new protocols that can use MPEG-TS for streaming over HTTP, that put additional metadata in files and fix the disadvantage I talked before. These are HTTP Live Streaming and DASH (Dynamic adaptive streaming over HTTP).

On the other hand MP4 has that info in part of the stream, called moov atom. The point is that the moov must be placed before the media content and downloaded from the server first.This way the video player knows the duration and can seek to any point without downloading the whole file (this is called HTTP pseudostreaming).

Sadly ffmpeg places the moov at the end of the file. You can fix that with software like Xmoov-PHP.

Here you can find more info about pseudostreaming.