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. uCGUI窗口初始化过程

    一.相关结构体和变量 重要的uCGUI系统全局变量 NextDrawWin                      下一个需要重绘的窗口句柄 WM__NumWindows       系统当前的总共 ...

  2. 8位灰度图在LCD上显示

    一.概述 1.灰度 灰度使用黑色调表示物体,即用黑色为基准色,不同的饱和度的黑色来显示图像.每个灰度对象都具有从 0%(白色)到灰度条100%(黑色)的亮度值. 使用黑白或灰度扫描仪生成的图像通常以灰 ...

  3. Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]:谢勤政-11061197,吴润凡-11061185

    一,关于结对编程 结对编程的优点: 1)在开发层次,结对编程能提供更好的设计质量和代码质量,两人合作能有更强的解决问题的能力. 2)对开发人员自身来说,结对工作能带来更多的信心,高质量的产出能带来更高 ...

  4. hdu 1255 覆盖的面积 (线段树处理面积覆盖问题(模板))

    http://acm.hdu.edu.cn/showproblem.php?pid=1255 覆盖的面积 Time Limit: 10000/5000 MS (Java/Others)    Memo ...

  5. MongoDB 覆盖索引查询

    MongoDB 覆盖索引查询 官方的MongoDB的文档中说明,覆盖查询是以下的查询: 所有的查询字段是索引的一部分 所有的查询返回字段在同一个索引中 由于所有出现在查询中的字段是索引的一部分, Mo ...

  6. 数组方法slice()把类数组转成数组和复制一个数组

    function a(){ console.log(arguments.length); var c = [].slice.call(arguments);//类数组转成数组 c.push(5); c ...

  7. Weex详解:灵活的移动端高性能动态化方案

    原文地址:http://www.infoq.com/cn/articles/introducing-weex 在2016年4月份的QCon上,阿里巴巴资深总监,淘宝移动平台及新业务事业部.阿里百川负责 ...

  8. Java集合框架的知识总结(1)

    说明:先从整体介绍了Java集合框架包含的接口和类,然后总结了集合框架中的一些基本知识和关键点,并结合实例进行简单分析. 1.综述 所有集合类都位于java.util包下.集合中只能保存对象(保存对象 ...

  9. 如何使用 Java8 实现观察者模式?(下)

    [编者按]本文作者是 BAE 系统公司的软件工程师 Justin Albano.在本篇文章中,作者通过在 Java8 环境下实现观察者模式的实例,进一步介绍了什么是观察者模式.专业化及其命名规则,供大 ...

  10. C语言关键字 - 铁布衫:const 转载

    const 描述:相传C世界中出现了一件极品装备const,它能的出现,让天下所有的刺客,黑客都失业了,在它的保护下,所有的变量都可以完好无损. 作用:const是constant的简写,表示海枯石栏 ...