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.

  • 相关阅读:
    ruby 实现java中的aes 加密解密
    移动端手机端web页面中背景图固定问题
    hooks 组件对应的生命周期
    React 生命周期函数总结
    Sequelize 常用增删改查函数
    如何验证SSH的连通性
    如何生成SSH密钥
    如何查看本机ssh秘钥
    如何更改本地代码仓库指向
    如何发布npm 包
  • 原文地址:https://www.cnblogs.com/welhzh/p/4962668.html
Copyright © 2011-2022 走看看