Forming Process of IPTV support TS Stream Solution

Source: Internet
Author: User
Tags unsupported

Live broadcasting: The existing Isma method. The process is as follows:

Video collection-> video encoding-> RTP packaging-> UDP multicast;

Audio collection-> Audio Encoding-> RTP packaging-> UDP multicast;

The above is the workflow of mp4live.

Live Video: mpeg ts stream mode. The process is as follows:

Video collection --> video encoding -->

Audio collection> Audio Encoding> TS packaging> RTP packaging> UDP multicast

The above is the workflow of TS stream.

On-demand video: Isma Mode

Read the audio and video data in the file, package the data to RTP, and send the data separately.

On-demand video: TS stream mode

Read the audio and video data in the file, package it into a TS stream, encapsulate it into RTP, and then send it out.

 

 

Now you need to do the following:

1. Set up an environment in September 30, 2010 to test whether the Darwin server supports ts streams. The test environment is as follows:

VLC --> Darwin --> VLC

A. We can achieve this goal in two steps: first test vlc1 --> vlc2

VLC streaming configuration can be configured through the graphical interface or through command lines.

Vlc1 requests media data from the Darwin server and then packs it into a TS stream and sends it out. vlc2 receives and plays TS stream data;

Throughout the process, packet capture proves that the TS stream is in the middle.

Of course, there is also a problem, that is, there will be mosaic in the image. It is assumed that there is a problem with the B frame PTS and DTs.

Another problem is that the SDP file cannot be generated because we need to implement step 2.

B. VLC --> Darwin --> VLC

The Darwin server needs an SDP file to describe the media source.

 

2. Problem: VLC cannot generate SDP files during the streaming process. Do you need to solve this problem?

Incorrect syntax:

VLC-vvv -- extraintf = logger rtsp: // 115.182.51.78/TV/xingkongdianying. SDP: sout = # duplicate {DST = RTP {DST = 224.1.2.3, MUX = ts, Port = 1234, SDP = "file: // C:/test. SDP "}}

Correct syntax:

VLC-vvv -- extraintf = logger rtsp: // 115.182.51.78/TV/xingkongdianying. SDP: sout = # duplicate {DST = RTP {DST = 224.1.2.3, MUX = ts, Port = 1234, SDP = "file: // 10.57.26.88/guoq/test_100.sdp "}}


3. Question: In the streaming process of VLC, the image quality is very poor, and the positioning problem is solved?

View logs and find:

Mux_ts warning: Packet With too strange DTS (DTS = 23955930833, old = 23956030944, PCR = 23956030944)

Mux_ts warning: Packet With too strange DTS (DTS = 23956097687, old = 23956197798, PCR = 23956197798)

Mux_ts warning: Packet With too strange DTS (DTS = 23956231175, old = 23956364663, PCR = 23956364663)

Mux_ts warning: Packet With too strange DTS (DTS = 23956398030, old = 23956531518, PCR = 23956531518)

Mux_ts warning: Packet With too strange DTS (DTS = 23956564885, old = 23956698373, PCR = 23956698373)

Mux_ts warning: Packet With too strange DTS (DTS = 23956731739, old = 23956831861, PCR = 23956831861)

Mux_ts warning: Packet With too strange DTS (DTS = 23956898593, old = 23956998715, PCR = 23956998715)

Mux_ts warning: Packet With too strange DTS (DTS = 23956278439, old = 23957011060, PCR = 23956931970)

Mux_ts warning: Packet With too strange DTS (DTS = 23957044802, old = 23957132191, PCR = 23957132191)

I still don't know how to solve the problem.

Moreover, the image is mosaic when streaming is configured on the GUI. There may be problems.

4. Live Video solution:

A) if problem 3 is solved, live streaming ts can be implemented through a solution;

B) If problem 3 cannot be solved, live streaming ts requires a development scheme. You can consider adding TS Streaming code in the middle of mp4live.

It is recommended to adopt solution B because we need to rewrite some information such as the PID, which must comply with the requirements of China Unicom, which cannot be solved by configuring VLC.

5. On-Demand file solution:

A) convert an MP4 file to a TS file and check whether Darwin can read and stream the file;

B) MP4 files are read by Darwin and Darwin, converted to ts streams, and streamed;

It has been verified that the Darwin server does not support streaming ts. In the describe stage of the RTSP command, the error code 514 is returned: Unsupported media type.

Request: Describe rtsp: // 10.57.26.88/test. Ts RTSP/1.0/R/n

Method: Describe

URL: rtsp: // 10.57.26.88/test. Ts

 

Response: RTSP/1.0 415 unsupported media type/R/n

Status: 415

 

The current solution has the following two options:

A) read MP4 and generate ts streams;

B) read ts files and generate ts streams;

 

6. Study the open source code of TS Stream

A) mpeg2t in mpeg4ip;

Extract the TS stream.

B) mux_ts in VLC;

C) is live555 available for reference?

Testmpeg2transportstreamer. cpp

D) libtsmux, an open source C library

E) mp4box, gpac.

Mp4file à ts file, or RTP, or UDP.

F) tstools

Esmerge. c

7. Live Video TS Stream Solution

Video collection --> video encoding -->

Audio collection> Audio Encoding> TS packaging> RTP packaging> UDP multicast

8. On-Demand TS Stream Solution

The Darwin server reads ts files, packs them into RTP data, and sends them out.

9. Convert MP4 files to ts files

VLC-vvv -- extraintf = logger D:/11.mp4: sout = # STD {access = file, MUX = ts, DST = D:/11.ts}

10. Convert MP4 files to ts streams

VLC-vvv -- extraintf = logger D:/11.mp4: sout = # duplicate {DST = RTP {DST = 224.1.2.3, MUX = ts, Port = 1234, SDP = "file: // 10.57.26.88/guoq/test_100.sdp "}, DST = display}

11. Create a test program

Read video data and audio data from MP4 files, package them into ts streams, package them into RTP packets, and send them out. You can use VLC to receive and play videos.

This section describes how the test program is developed in the IPTV development process supporting ts streams.

 

Objective: To Read audio and video data from an MP4 file, package it into a TS stream, and save it as a TS file. You can use VLC or storm video to play the file.

1. Read MP4 files and obtain audio and video data;

You can use the library in mpeg4ip to introduce the header file mp4.h to connect to libmp 4v2. so. For the writing method, refer to mp4creator.

Audio frames and video frames are obtained in sequence, and they are sorted by playback time.

Playback time calculation:

Audio_play_time = audio_timestamp * 1000/audio_timescale;

Video_play_time = video_timestamp * 1000/video_timescale;

2. At this time, the es stream is obtained. Es is packaged into a PES package, and PES is packaged into a TS package. In fact, we have omitted something to say that ES needs to do something before it is packaged as PES:

Video es. If it is the first frame, you need to add the videostreamheader. Each encoding format, such as H.264 or MP4, is different. Each encoding format needs to obtain its own unique videostreamheader.

Audio es, the audio of each frame must be added with the audiostreamheader. Each encoding format, such as AAC, must be obtained independently.

A. H.264, define a Ar hsf-_delimeter [4] = {0x00, 0x00, 0x00, 0x01 };

The first one is hsf-_delimeter [4], 0x09, 0xe0;

The second is hsf-_delimeter [4], seqheader;

The third is hsf-_delimeter [4], pictheader;

B. MP4, MP2, MP1, mp4gettrackesconfiguration;

C. AAC audio, which contains seven bytes of ADTs Fixed Header information. You must set the length of each frame of audio data, so each frame must be changed.

3. es --> PES

PES headers need to be constructed, and PTS and DTS need to be tagged;

4. PES --> TS

To construct the TS header, We need to tag the PCR, and divide PES into several smaller than 188 pieces. The length is usually 184, or 184-8; the 8 bytes is the PCR information.

Of course, for the entire TS stream, a pat table is required to tell us how many programs program;

Several other PMT tables are needed. The PMT table tells us how many Es streams are included in this program.

 

From http://hi.baidu.com/goggle1/blog/item/b3665dc3c753c13ae5dd3b13.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.