http://stackoverflow.com/questions/4145575/transport-stream-mpeg-file-fromat

What you are probably wanting to do is convert from MPEG-TS (Transport Stream) to MPEG-PS (Program Stream). MPEG-PS is the format of a standard .mpg file as well as the format DVD video uses.

You probably should get a hold on the standard which is ISO/IEC 13818-1. This standard contains all of the MPEG-TS and MPEG-PS container details (it does not cover the coded video which is covered in ISO/IEC 13818-2).

Luckily, this conversion is rather simple since most of the entire MPEG-PS structure is contained within the MPEG-TS format. The transport stream contains a series of 188 byte packets that each have a header. PES (Program Elementary Stream) packets are contained within the packet payloads. PES packets contain the actual video or audio payload. A PES packet can be any length and most of the time they span several TS packets. Demuxing the PES packets from the transport stream really just involves removing the TS headers and concatenating the payload data correctly to form the PES packets.

Once you have a stream of PES packets, you will multiplex them into the Program Stream format as laid out in the standard. So basically, you don't need to parse the PES packets or their content, you can just lift them from one format and insert them into the other.

Even though the conversion is fairly simple, it still requires quite a bit of work since you will need to become pretty familiar with the container standard and be meticulous with your parsing of the bitstream to get things right. So even though I say the conversion is simple, that is only in the sense that it is simple compared to other format conversions where you might have to dig down further into the video data.

I am trying to add some good resources that might help.

Here are some documents that explains the details of Transport and Program streams and associated packetization structures.

  1. This explains the differences between Transport stream and Program stream. http://www.vbrick.com/docs/VB_WhitePaper_TransportStreamVSProgramStream_rd2.pdf

  2. This explains the over view of MPEG and includes packetization as well. http://www.img.lx.it.pt/~fp/cav/Additional_material/MPEG2_overview.pdf

  3. THis explains the other aspects of transport streams on how programs are selected using tables etc. http://www.bitrouter.com/pdf/tutorial-psip.pdf

Basically, you need to depacketize the transport stream and decompose into PES packets (along with the time stamps) and then apply the program stream packetization process.

The crucial thing is how do you maintain the relative gap and timing of the packets in PS streams when you mux it back. Hence, you must preserve the PTS/DTS timestamps in the PES packets.

I am listing some tools here - that are good example for part of your work - and they are better known to be with compliance to MPEG2 systems standard.

  1. tstools ( http://tstools.berlios.de/)
  2. mplex (from mjpegtools)
  3. dvb-mplex (part of libdvb, http://www.metzlerbros.org/dvb/)
  4. DVB-replax (also part of libdvb, http://freshmeat.net/projects/dvb-replex/ or http://www.metzlerbros.org/dvb/)
  5. avidemux. http://avidemux.sourceforge.net/

Another good way to begun learning is to use Gstreamer plug-in framework if you want to understand the broader flow quickly.

FFMPEG can be used to convert from a TS to MPEG. More info here.

pes and ts stream, how to convert的更多相关文章

  1. TS Stream 详解

    <什么是TS>     TS(transport stream) , TS流文件,是一种DVD的文件格式,TS格式的特点就是要求从视频流的任一片段开始都是可以独立解码的,这种特性就决定了T ...

  2. 多媒体开发之--- rtsp 中的H264 编码+打包+解码相关知识es、pes、ts...

    1)ES流(Elementary Stream): 也叫基本码流,包含视频.音频或数据的连续码流. 2)PES流(Packet Elementary Stream): 也叫打包的基本码流, 是将基本的 ...

  3. ES PES TS

    1.流媒体系统结构 ES:elemental stream 基本数据流: PES:packet elemental stream分组的基本数据流: 然后把PES打包成PS ,TS流,PS:progra ...

  4. Java – How to convert Array to Stream

    Java – How to convert Array to Stream 1. Object Arrayspackage com.mkyong.java8; import java.util.Arr ...

  5. 分析ffmpeg解析ts流信息的源码

    花费一些时间,然后全部扔了.为了不忘记和抛砖引玉,特发此贴. ffmpeg解析ts流 1.目的     打算软件方式解析出pat,pmt等码流信息 2.源代码所在位置         下载ffmpeg ...

  6. TS 流的解码过程(系摘抄)

    TS 流解码过程: 1. 获取TS中的PAT 2. 获取TS中的PMT 3. 根据PMT可以知道当前网络中传输的视频(音频)类型(H264),相应的PID,PCR的PID等信息. 4. 设置demux ...

  7. TS 流解码过程

    TS 流解码过程: 1. 获取TS中的PAT 2. 获取TS中的PMT 3. 根据PMT可以知道当前网络中传输的视频(音频)类型(H264),相应的PID,PCR的PID等信息. 4. 设置demux ...

  8. H264 TS/ES

    ES流(Elementary Stream): 也叫基本码流,包含视频.音频或数据的连续码流.       PES流(Packet Elementary Stream): 也叫打包的基本码流, 是将基 ...

  9. TS 数据流分析学习

    TS 流.包结构以及同步 1. TS 流: 可以将TS流理解为一种单一码流.混合码流. 单一码流:TS流的基本组成单位是长度为188字节的TS包. 混合码流:TS流有多种数据组成,一个TS包中的数据可 ...

随机推荐

  1. Ubuntu启动停止在checking battery state...

    Ubuntu在“checking battery state...”处停止了,出现这种现象的原因可能有很多种.笔者遇到的是其中的一种. 情景描述: 笔者此前将Ubuntu的图形启动方式修改为了字符界面 ...

  2. Linux和Windows下查看环境变量方法对比

    摘自:Linux和Windows下查看环境变量方法对比 一.查看所有环境变量的名称和值 Linux下:export Windows下:set 二.根据名称查该环境变量的值 Linux下:echo $环 ...

  3. java转义字符(转载)

    转载自:http://blog.163.com/dingyi_57@126/blog/static/110479195200911229337281/ 一.为什么要使用转义字符? 1.  HTML中& ...

  4. C#微信登录-电脑版扫描二维码登录

    像京东,一号店等网站都实现了用微信来登录的功能,就是用手机上的微信扫一扫网站上的二维码,微信上确认后,即可自动用微信的帐号登录网站. 一.创建网站应用 在微信开放平台创建一个网站应用 https:// ...

  5. 一步步学习ASP.NET MVC3 (12)——FileResult

    请注明转载地址:http://www.cnblogs.com/arhat 忙了两天,本来老魏昨天就应该写出新的文章,但是由于昨天雨夹雪而且加上昨天晚上加了班,到家都没饭吃了,一看时间都9点了,什么饭店 ...

  6. python xlrd,xlwt 读写excel文件

    python 读excel文件,需要xlrd库.下载地址:https://pypi.python.org/pypi/xlrd python 写excel文件,需要xlwt库.下载地址:https:// ...

  7. 什么是实时应用程序自我保护(RASP)?

    什么产品可以定义为 RASP? RASP 英文为 Runtime application self-protection,它是一种新型应用安全保护技术,它将保护程序想疫苗一样注入到应用程序和应用程序融 ...

  8. HDU3400+三分

    三分出两个中间的位置即可. /* 两次三分 */ #include<stdio.h> #include<string.h> #include<stdlib.h> # ...

  9. Mysql的列索引和多列索引(联合索引)

    转自:http://blog.chinaunix.net/uid-29305839-id-4257512.html 创建一个多列索引:CREATE TABLE test (      id       ...

  10. ZOJ 3817 Chinese Knot

    题意:给定4个长度为N的字符串( N <= 100000),然后构成一个“中国结”,给定目标串,问能否从某个节点出发走一遍得到目标串,其中不能连续通过3个中心节点,也就是从字符串一个端点转移到其 ...