zoukankan      html  css  js  c++  java
  • pes and ts stream, how to convert

    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.

  • 相关阅读:
    phonegap开发入门
    [转] jQuery源码分析-如何做jQuery源码分析
    【转】HTML,CSS,font-family:中文字体的英文名称 (宋体 微软雅黑)
    iframe子页面与父页面通信
    5.10团队冲刺
    5.10日
    5.9日团队冲刺
    5.9日自学成果
    5.8日团队冲刺
    5.7日团队冲刺
  • 原文地址:https://www.cnblogs.com/welhzh/p/4962668.html
Copyright © 2011-2022 走看看