CN113747209B - Method and device for reorganizing multi-channel TS (transport stream) programs - Google Patents

Method and device for reorganizing multi-channel TS (transport stream) programs Download PDF

Info

Publication number
CN113747209B
CN113747209B CN202110881665.8A CN202110881665A CN113747209B CN 113747209 B CN113747209 B CN 113747209B CN 202110881665 A CN202110881665 A CN 202110881665A CN 113747209 B CN113747209 B CN 113747209B
Authority
CN
China
Prior art keywords
pcr
output
stc
program
stream
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110881665.8A
Other languages
Chinese (zh)
Other versions
CN113747209A (en
Inventor
单琳伟
毛珂
樊晓婷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
National Engineering Laboratory For Digital Tv Beijing Co ltd
Original Assignee
National Engineering Laboratory For Digital Tv Beijing Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by National Engineering Laboratory For Digital Tv Beijing Co ltd filed Critical National Engineering Laboratory For Digital Tv Beijing Co ltd
Priority to CN202110881665.8A priority Critical patent/CN113747209B/en
Publication of CN113747209A publication Critical patent/CN113747209A/en
Application granted granted Critical
Publication of CN113747209B publication Critical patent/CN113747209B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/242Synchronization processes, e.g. processing of PCR [Program Clock References]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/236Assembling of a multiplex stream, e.g. transport stream, by combining a video stream with other content or additional data, e.g. inserting a URL [Uniform Resource Locator] into a video stream, multiplexing software data into a video stream; Remultiplexing of multiplex streams; Insertion of stuffing bits into the multiplex stream, e.g. to obtain a constant bit-rate; Assembling of a packetised elementary stream
    • H04N21/23608Remultiplexing multiplex streams, e.g. involving modifying time stamps or remapping the packet identifiers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/434Disassembling of a multiplex stream, e.g. demultiplexing audio and video streams, extraction of additional data from a video stream; Remultiplexing of multiplex streams; Extraction or processing of SI; Disassembling of packetised elementary stream

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The application discloses a method and a device for reorganizing multi-channel TS programs, and relates to the technical field of digital televisions. The method comprises the following steps: the demultiplexing module demultiplexes the N paths of TS streams; the decoding module generates PCR/STC sample value pairs of each program and decodes video and audio; the system time management module calculates and obtains a PCR '/STC' sample value pair according to a preset mapping relation; the grouping and combining module recombines the decoded video and audio; the coding module carries out coding compression on each path of recombined video and audio, calculates PCR information of each path of output program, and carries out TS encapsulation; the multiplexing output module multiplexes the output program stream into a TS stream. The application is suitable for the TS stream program recombination in the digital television field, realizes the regrouping and merging of the audios and videos of different programs in a plurality of TS streams, eliminates the influence of system time errors, solves the problem of frame loss or blocking of the merged new program, and can meet the high-quality program conversion requirement.

Description

Method and device for reorganizing multi-channel TS (transport stream) programs
Technical Field
The application relates to the technical field of digital televisions, in particular to a method and a device for recombining multi-channel TS (transport stream) programs.
Background
In the program creation, guiding and encoding apparatus, an application scenario is to re-group and combine audio and video of different programs in multiple TS streams (Transport streams) to generate a new program combination. For example, let us assume that there are two TS stream inputs in the system, TS1 and TS2, there are 1 program P1 in TS1, and P1 contains 1 video V1 and 1 audio A1; the TS2 contains 1 program P2, and the P2 contains 1 video V2 and 1 audio A2. According to the service scene requirement, V1 and A2 need to be recombined into 1 new program P3. However, since V1 and A2 originate from different programs P1 and P2, not only the audio/video data itself is processed during the merging, but also a new PCR needs to be generated during the merging due to the different PCRs (Program Clock Reference, program reference clocks) of the two programs, and the new PCR needs to have a mapping relationship with the PCRs in the original P1 and P2. If the mapping conversion relation is not processed well, the frame loss or the blocking of the video can be caused due to the accumulated error of the time stamp.
Disclosure of Invention
The application aims to solve the technical problem of providing a method and a device for reorganizing multi-channel TS programs aiming at the defects of the prior art.
The technical scheme for solving the technical problems is as follows:
a method for reorganizing multi-channel TS stream programs includes:
the demultiplexing module obtains N paths of TS streams, demultiplexes the N paths of TS streams to obtain N paths of programs, and sends the N paths of programs to the decoding module;
when receiving the PCR information of the N paths of programs, the decoding module records the current STC (System Time Clock, system clock) information, generates PCR/STC sample value pairs of each path of program, and sends the PCR/STC sample value pairs of each path of program to a system time management module; decoding the video and audio of the N paths of programs, and sending the decoded video and audio to a packet merging module;
the system time management module stores the PCR/STC sample value pairs of the N paths of programs in N paths of input queues, calculates and obtains the PCR '/STC sample value pairs in the corresponding output queues according to a preset mapping relation, and sends the obtained PCR'/STC sample value pairs in all the output queues to the coding module;
the grouping and combining module is used for recombining the decoded video and audio according to a preset recombination requirement to obtain at least one path of recombination result, and transmitting all the obtained recombination results to the coding module;
the coding module carries out coding compression on each path of video and audio after recombination, calculates PCR information of each path of output program according to the PCR '/STC' sample value in the corresponding output queue, carries out TS encapsulation on each path of video and audio corresponding to the coding compression according to the PCR information of each path of output program, obtains at least one path of output program stream, and sends all obtained output program streams to the multiplexing output module;
multiplexing the at least one output program stream into at least one TS stream by the multiplexing output module;
wherein N is more than or equal to 2.
The other technical scheme for solving the technical problems is as follows:
a storage medium having instructions stored therein, which when read by a computer, cause the computer to perform the method for reorganizing a multi-channel TS stream program according to the above technical solution.
The other technical scheme for solving the technical problems is as follows:
a reorganization apparatus of a multi-channel TS stream program, comprising:
a memory for storing a computer program;
and the processor is used for executing the computer program to realize the method for reorganizing the multi-channel TS stream programs according to the technical scheme.
The beneficial effects of the application are as follows: the method and the device provided by the application are suitable for TS stream program recombination in the digital television field, PCR/STC sample pairs of programs are generated through a decoding module, the PCR/STC sample pairs of the programs are mapped through a system time management module, the video and the audio are recombined through a grouping and combining module, and then corresponding video and audio of each path after coding and compression are subjected to TS encapsulation according to the PCR information of each path of output program, so that the audio and video of different programs in a plurality of TS streams are recombined and combined, the influence of system time errors is eliminated, the condition of frame loss or clamping of the combined new programs is solved, and the high-quality program conversion requirement can be met.
Additional aspects of the application will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the application.
Drawings
FIG. 1 is a schematic flow chart of a reorganization method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a system module according to an embodiment of the reorganization method of the present application;
FIG. 3 is a schematic diagram of an input/output queue mapping relationship provided in an embodiment of a reorganization method according to the present application;
fig. 4 is a schematic view of a structural framework provided by an embodiment of the reorganization device of the present application.
Detailed Description
The principles and features of the present application are described below with reference to the drawings, the illustrated embodiments are provided for illustration only and are not intended to limit the scope of the present application.
At present, most of existing systems do not support free combination of video and audio among multiple programs, but adopt a mode of overall program switching, and cannot deal with the problem that audio and video in new programs possibly come from different program sources, so that application scenes are limited, higher requirements are provided for program production equipment, and better flexibility and compatibility are not provided.
In addition, in the existing scheme, there is no method for mapping and converting the PCR of the new program and the original PCR, but a new time is regenerated according to the frame rate by using a local or external clock. This implementation, while simple, has the problem of not being consistent with the original time. Because the original program is sourced from different systems, if the equipment for producing and transmitting the program and the equipment for recombining and combining the program are different, the system time error must exist between the equipment. If a new PCR is used in the new program instead of the original time, the system time error is accumulated continuously, resulting in the blocking or frame loss of the new program, especially in the case of real-time program processing, so that the high-quality program conversion requirement cannot be satisfied.
Finally, in the existing scheme, a data copying mode is basically adopted in video data processing, but because the video data volume is large, the copying mode can consume a large amount of operation and I/O resources of the system, and the processing delay of the system is increased, so that the processing capacity requirement and the end-to-end delay of the whole system are increased.
Based on the above problems, the present application provides a method and apparatus for recombining and merging multiple TS stream programs, which are further described below.
As shown in fig. 1, a flow chart is provided for an embodiment of the reorganization method of the present application, where the reorganization method is used for reorganizing multiple TS programs, and is implemented based on a reorganization system shown in fig. 2, and the reorganization system includes: a demultiplexing module 1, a decoding module 2, a system time management module 3, a packet merging module 4, an encoding module 5, and a multiplexing output module 6, and a reassembly method will be described below in connection with the reassembly system, where the reassembly method includes:
s1, a demultiplexing module 1 obtains N paths of TS streams, demultiplexes the N paths of TS streams to obtain N paths of programs, and sends the N paths of programs to a decoding module 2;
it should be understood that a PCR that includes one video, at least zero audio, and this program, for example, a PCR that includes 1 video, 5 audio, and this program for the 1 st program, a PCR that includes 1 video and this program for the 2 nd program, and a PCR that includes 1 video, 1 audio, and this program for the 3 rd program.
After demultiplexing by the demultiplexing module 1, only program information exists, and it is not recorded from which TS stream each program originates. The program information refers to information related to a program, such as video, audio, PCR, etc. included in the program, and PSI information (program specific information) may be added according to service requirements, etc.
All the demultiplexed information is sent to the decoding module 2 in real time to maintain the time base line information of the source program.
Alternatively, a unique integer number may be set for each program to be output for subsequent encoding, for example, 1 may be added sequentially from 1, such as program 1, program 2, program 3, and the like.
S2, when receiving the PCR information of the N paths of programs, the decoding module 2 records the current STC information, generates PCR/STC sample value pairs of each path of program, and sends the PCR/STC sample value pairs of each path of program to the system time management module 3; decoding the video and audio of the N paths of programs, and sending the decoded video and audio to the packet merging module 4;
it should be appreciated that the PCR/STC sample pairs are the basis for tracking the PCR time drift of the incoming program and that the decoding module 2 feeds the value pairs to the system time management module 3.
The format information of video and audio may be transmitted to the packet combining module 4 through a message.
Alternatively, the discontinuity information may be added at the same time when the sample pair is fed into the system time management module 3, so as to prompt the system time management module 3 whether the sample pair is a discontinuity.
Where STC is the system clock.
S3, the system time management module 3 stores the PCR/STC sample value pairs of the N paths of programs in N paths of input queues, calculates the PCR '/STC sample value pairs in the corresponding output queues according to a preset mapping relation, and sends the obtained PCR'/STC sample value pairs in all the output queues to the coding module 5;
the system time management module 3 is used for recording the clock characteristics of each path of input program and generating the clock of the output program according to the mapping relation of the input and the output.
It should be appreciated that each incoming program has an input queue for storing all PCR/STC sample pairs for that program; similarly, each output program has an output queue for storing pairs of PCR '/STC' samples for the output program. The number of input queues and output queues may be different, but one-to-one or one-to-many mapping is required, i.e. one input queue may be mapped to one or more output queues, but a many-to-one mapping is not allowed, i.e. multiple input queues may not be mapped to the same output queue.
After the mapping of the input/output queues satisfies the one-to-one and one-to-many mapping relationships, a specific mapping relationship can be configured by a user.
For example, as shown in FIG. 3, an exemplary I/O queue mapping is provided in which A and B in the I/O queue represent different pairs of PCR/STC samples for the same I/O program and A 'and B' in the I/O queue represent different pairs of PCR '/STC' samples for the same I/O program.
In fig. 3, the number of input queues is m, the number of output queues is n, and the number corresponds to m input programs and n output programs, respectively. In fig. 3, the specific mapping relationship is: input queue 1 maps to output queue 1; input queue 2 maps to output queues 3 and 4; the input queue 3 maps to the output queue 2; the input queue m maps to the output queue n.
In addition, there is one PCR per output queue offset The PCR overall time difference for recording the input and output programs with the mapping relation can be configured by a user according to actual requirements.
It should be understood that, in the corresponding relation of input and output, the present embodiment uses video as the basis of mapping, that is, if video of one input program is combined by grouping to become video of another output program, the PCR/STC queue of the input program will be mapped to the corresponding output PCR '/STC' queue, where for convenience of presentation, the input program number and the input queue number are made consistent, and similarly, the output program number and the output queue number are made consistent.
S4, the grouping and combining module 4 performs recombination on the decoded video and audio according to a preset recombination requirement to obtain at least one path of recombination result, and all the obtained recombination results are sent to the encoding module 5;
it should be noted that, the packet merging module 4 is configured to establish a correspondence between input and output audio/video, where the input and output have a relationship of 1 to 1 and 1 to more, but there is no relationship of 1 to 1 more, that is, 1 output audio/video has only 1 input audio/video.
For example, 1 input video corresponds to 1 output video, or 1 input video corresponds to 3 output videos, but 1 output video cannot correspond to 3 input videos.
Specific reorganization requirements can be configured by a user according to actual requirements, in order to facilitate regrouping, the grouping and merging module 4 can number the input audios and videos respectively, and 1 can be added sequentially from 1, for example, 3 input videos can number as input video 1, input video 2 and input videos 3,4 audios can number as input audio 1, input audio 2, input audio 3 and input audio 4.
The output audio/video is grouped according to the reorganization requirement of the output program, for example, the output program 1 includes output video 1, output audio 1 and output audio 3, and then the output video 1, the output audio 1 and the output audio 3 are grouped.
Wherein the output video 1 may be derived from the input video 2, the output audio 1 may be derived from the input audio 2, and the output audio 3 may be derived from the input audio 3.
The packetized audio and video is sent to the following encoding module 5 in accordance with the program groups for further processing by the encoding module 5.
Preferably, in order to avoid delay and overhead caused by copying data, the data transfer is performed by transferring a ring buffer handle, and the latter encoding module 5 obtains the ring buffer handle corresponding to the audio or video in the program, and then directly obtains the audio or video data from the ring buffer handle.
S5, the coding module 5 codes and compresses each path of recombined video and audio, calculates PCR information of each path of output program according to the PCR '/STC' sample value in the corresponding output queue, TS packages each path of video and audio corresponding to the codes and compressed according to the PCR information of each path of output program to obtain at least one path of output program stream, and sends all the obtained output program streams to the multiplexing output module 6;
for example, each path of recombined video and audio codes may be compressed into AAC, AC3, AVC, HEVC, etc. formats.
It should be appreciated that the time stamp information for each output program is stored in an output queue of the system time management module 3. For convenience, the output program group number may be set to coincide with the output queue number of the system time management module 3.
S6, multiplexing at least one output program stream into at least one TS stream by the multiplexing output module 6, wherein the output TS stream is sent to a subsequent transmission or playing link;
wherein N is more than or equal to 2.
The method and the device for reorganizing TS stream programs are suitable for reorganizing TS stream programs in the digital television field, PCR/STC sample pairs of the programs are generated through the decoding module 2, the PCR/STC sample pairs of the programs are mapped through the system time management module 3 by using a preset mapping relation, video and audio are reorganized through the grouping merging module 4, corresponding video and audio after coding compression are subjected to TS encapsulation according to PCR information of each output program, the fact that audio and video of different programs in a plurality of TS streams are reorganized and merged is achieved, the influence of system time errors is eliminated, the condition that new merged programs are lost in frames or blocked is solved, and high-quality program conversion requirements can be met.
Optionally, in some possible embodiments, the decoding module 2 further includes, before sending the PCR/STC sample pairs of each program to the system time management module 3:
judging whether each PCR/STC sample value pair of each program is a discontinuous point or not through a discontinuous indication mark bit in the TS stream, and if the current sample value pair is the discontinuous point, adding a discontinuous point mark for the current sample value pair;
if the current sample pair is not a discontinuity, then a discontinuity identification is added to the current sample pair if the current sample pair satisfies the following formula:
|PCR 2 -PCR 1 |>|STC 2 -STC 1 |×G
it will be appreciated that at least 2 PCR/STC pairs will be able to determine the discontinuity, wherein PCR 2 /STC 2 For the current sample pair, PCR 1 /STC 1 G is a predetermined constant for the previous sample pair of the current sample pair.
It should be noted that, the discontinuous indication flag bit may be determined by a discontinuity_indicator flag bit in the TS header, and if the flag bit is 1, the current sample pair of the flag is a discontinuous point; if the flag bit is 0, the discontinuity point is judged through the formula.
Alternatively, G may be 3/50000+27, assuming that the maximum drift of the system clock at the receiving end is ±30ppm, so the absolute value of the maximum drift is 60ppm, that is, 60=3/50000 parts per million, and 27 is the maximum self 10ppm drift of the 27MHz clock, that is, 27 mhz=27 parts per million.
It will be appreciated that these two thresholds may be increased depending on the clock conditions of the actual system.
Alternatively, in some possible embodiments, the encoding module 5 calculates PCR information of each output program according to the PCR '/STC' sample pair in the corresponding output queue, specifically including:
judging whether the PCR '/STC' sample value pair in the corresponding output queue is a continuous sample value pair according to the discontinuous point mark, and calculating the PCR information of each output program according to the following conditions aiming at the continuous sample value pair:
if STC p Greater than the STC' of all sample pairs in the corresponding output queue, and PCR min ′/STC min ' continuous sample centering STC min ' and STC p The absolute difference between the STC ' and the PCR '/STC ' sample pair of the total output queue p The minimum value of the absolute value of the difference value of (2), the PCR information PCR of the current output program is calculated according to the following formula p
PCR p =PCR min ′+STC p -STC min ′;
If STC p Less than the STC' of all sample pairs in the corresponding output queue, and PCR min ′/STC min ' continuous sample centering STC min ' and STC p The absolute difference between the STC ' and the PCR '/STC ' sample pair of the total output queue p The minimum value of the absolute value of the difference value of (2), the PCR information PCR of the current output program is calculated according to the following formula p
PCR p =PCR min ′+STC min ′-STC p
If STC p First PCR in corresponding output queue 1 ′/STC 1 STC in' successive sample pairs 1 ' and second PCR 2 ′/STC 2 STC in' successive sample pairs 2 ' between them, the PCR information PCR of the current output program is calculated according to the following formula p
PCR p =(PCR 2 ′-PCR 1 ′)×(STC p -STC 1 ′)÷(STC 2 ′-STC 1 ′)+PCR 1 ′;
wherein ,STCp To output the current system time of the program.
It will be appreciated that the encoded video data and audio data may be inserted into the program stream at the following points in time:
PCR p =DTS-VBV Delay
wherein DTS is a decoding time stamp of each frame of data, VBV Delay Is defined in the standard ISO/IEC 13818-1T-STD buffer model and may be provided by the coding unit.
The program stream generated by the encoding module 5 is sent to the multiplexing output module 6, and in order to facilitate multiplexing synthesis by the multiplexing output module 6, the program stream generated by the encoding module 5 may use a constant bit rate mode, and empty packets may be inserted to maintain a constant bit rate if necessary.
Optionally, in some possible embodiments, the decoding module 2 decodes video and audio of the N-channel program, specifically including:
respectively decoding video and audio of the N paths of programs according to a preset format;
for example, video may be decoded into YCbCr format and audio may be decoded into PCM format.
Respectively establishing a first annular cache and a second annular cache according to the video format and the audio format of each program;
detecting whether the residual spaces of the first annular cache and the second annular cache meet a preset space storage value or not respectively;
if the first annular cache meets the preset space storage value, storing the decoded video in the first annular cache;
if the second annular buffer meets the preset space storage value, storing the decoded audio in the second annular buffer;
otherwise, the decoded video and the video are put into a queuing queue until the first annular buffer or the second annular buffer meets a preset space storage value, and then the decoded video and the video are taken out from the queuing queue for storage.
It should be noted that the ring buffer is a section of continuous main memory area, and ring-shaped means that when data is read or written to the last of the main memory areas, the logic judgment jumps to the beginning of the continuous main memory area to continue reading or writing. The establishing process is to allocate a section of continuous storage area according to the required size and set corresponding read-write pointers, etc.
The ring buffer is shared by the decoding module 2 and the encoding module 5, and the decoded original data is put into the ring buffer. Before decoding, the decoding module 2 checks whether the output ring buffer has enough residual space, and continues decoding if the residual space has at least one frame size, otherwise, the decoding of the video or audio will wait until the encoder consumes a part of the data in the ring buffer, and continues decoding if the residual space is greater than or equal to one frame. The buffer size is determined according to the decoded format and stores 200ms data, and can also be reduced or increased according to the condition of the system memory resource, and the byte size of the ring buffer is determined by the following formula:
wherein, bufferSize is the byte size of the ring buffer, frame size is the size of each frame of YCbCr data, frame rate is the frame rate of video, sampleRate is the sampling rate of audio, bitDepth is the audio bit depth, and channelnum is the number of audio channels.
Optionally, in some possible embodiments, the system time management module 3 calculates PCR '/STC' sample pairs in the corresponding output queues according to a preset mapping relationship, which specifically includes:
setting PCR integral time difference PCR of input program and output program recorded with mapping relation for every output queue offset
The PCR '/STC' sample pair in the corresponding output queue is calculated according to the following formula:
PCR′=PCR+PCR offset
STC′=STC。
wherein ,PCRoffset Can be configured by a user according to actual requirements.
It should be appreciated that when the PCR/STC sample pair of the input queue contains a discontinuity identification, the PCR '/STC' sample pair of the output queue retains the discontinuity identification of the corresponding PCR/STC sample pair of the input queue.
Optionally, in some possible embodiments, the multiplexing output module 6 multiplexes at least one output program stream into at least one TS stream, specifically including:
BitRate according to the total bit rate of the TS stream to be output T And the total bit number of the standard TS packets, calculating the transmission time required by each TS packet;
for example, the transmission Time Time required for each TS packet can be calculated according to the following formula perPacket
Time perPacket =188×8÷BitRate T
Wherein 188 x 8 represents the total number of bits of a standard TS packet, 188 represents 188 bytes, which is the length of one TS packet defined in standard ISO/IEC13818-1, 8 represents 8 bits, which is the number of bits contained in one byte.
Respectively calculating the number of bits to be output by each output program in the single TS packet time according to the transmission time required by each TS packet;
for example, the number of bits BitCountPerPacket that the nth output program should output within a single TS packet time can be calculated according to the following formula n
BitCountPerPacket n =BitRate n ×Time perPacket
Wherein BitRate n Representing the bit rate of the output program of the first pass.
Calculating the total bit number of each output program according to the bit number of each output program to be output in the single TS packet time;
for example, the total number of bits totalBitCount for each output program can be calculated piecewise according to the following formula n k
Where K is the TS packet sequence number of the entire TS stream, k=0, 1,2, …, K is the number of TS packets of the entire TS stream, n is the program sequence number, n=1, 2 … m, and m is the number of output programs of the current TS stream.
When the total bit number of any output program reaches the total bit number of the standard TS packet, one TS packet is taken out of any output program according to the input sequence and is inserted into the TS stream to be output, and then the total bit number of any output program is updated.
For example, the total number of bits may be updated according to the following formula:
optionally, in some possible embodiments, the method further includes:
when the total bit number of at least two paths of output programs reaches the total bit number of a standard TS packet, determining the priority order of each path of output programs according to the conflict times, the total bit rate of the TS stream to be output and the bit rate of each path of output programs, and selecting one path of output programs for output according to the priority order;
the output program which is not output is transferred to the next TS packet, so that the conflict times are increased, and the priority judgment is carried out again.
Optionally, in some possible embodiments, the priority order of each output program is determined according to the following steps:
if the conflicted output program contains PCR packets, setting the output program containing the PCR packets as the highest priority;
if TS packets to be inserted in the conflicting output programs are empty packets, discarding the empty packets;
if the conflicting output programs do not contain PCR packets and the TS packets to be inserted are not null packets, the priority of each output program is calculated according to the following formula:
wherein ,indicating priority of the nth output program at C time of conflict, bitRate n Bit rate, bitRate, representing the n-th output program T Represents the total bit rate of the TS stream to be output, C represents the number of collisions, 24 is a preset value,<<representing a left shift operation, representing shifting the bit rate of the nth output program left by 24 bits to increase the value.
It should be noted that, all variables in the formula are converted into 64-bit integers, so as to ensure that data cannot overflow, wherein C is 1 when a conflict occurs for the first time, if the program is not output under the current conflict, i.e. the priority is not the highest, c=c+1 is caused when the next output packet priority is judged.
The conflict selection method comprises the following steps: firstly, selecting the program output with the highest priority under the current conflict; the other programs which are not output are moved to the next TS packet, priority judgment is carried out again, and C=C+1 of the programs is carried out again, in addition, new conflict programs can be added in the next TS packet, C is set to be 1 for the newly added conflict programs, finally, priority judgment is carried out uniformly for all conflict programs including the programs which are delayed by the last conflict and are newly added by the conflict, the judgment of PCR and blank packets in the steps is carried out, and then the programs with the highest priority are output. The program which is not output is moved to the next output TS packet for priority judgment, and so on.
It will be appreciated that in some embodiments, some or all of the above embodiments may be included.
The present application also provides a storage medium, in which instructions are stored, which when read by a computer, cause the computer to execute the method for reorganizing multi-channel TS stream programs as disclosed in any of the above embodiments.
As shown in fig. 4, a schematic structural frame provided by an embodiment of a reorganizing apparatus according to the present application, where the reorganizing apparatus is used for reorganizing multiple TS stream programs, and includes:
a memory 10 for storing a computer program;
and a processor 20, configured to execute a computer program to implement the method for reorganizing multiple TS stream programs as disclosed in any of the foregoing embodiments.
The reorganizing device provided by the embodiment is suitable for the TS stream program reorganizing in the digital television field, PCR/STC sample pairs of programs are generated through the decoding module, the PCR/STC sample pairs of the programs are mapped through the system time management module, the preset mapping relation is used, the video and the audio are reorganized through the grouping merging module, and then the corresponding video and audio after coding compression are subjected to TS encapsulation according to the PCR information of each output program, so that the audio and video of different programs in a plurality of TS streams are regrouped and merged, the influence of system time errors is eliminated, the condition that the new merged program loses frames or is blocked is solved, and the high-quality program conversion requirement can be met.
It should be noted that, each of the foregoing embodiments is a product example corresponding to the previous method example, and for the description of the product embodiment, reference may be made to the corresponding description in each of the foregoing method embodiments, which is not repeated herein.
The reader will appreciate that in the description of this specification, a description of terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the method embodiments described above are merely illustrative, e.g., the division of steps is merely a logical function division, and there may be additional divisions of actual implementation, e.g., multiple steps may be combined or integrated into another step, or some features may be omitted or not performed.
The above-described method, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a Read-only memory (ROM), a random access memory (RAM, randomAccessMemory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The present application is not limited to the above embodiments, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the present application, and these modifications and substitutions are intended to be included in the scope of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (10)

1. A method for reorganizing a multi-channel TS stream program, comprising:
the demultiplexing module obtains N paths of TS streams, demultiplexes the N paths of TS streams to obtain N paths of programs, and sends the N paths of programs to the decoding module;
when receiving the PCR information of the N paths of programs, the decoding module records the current STC information, generates PCR/STC sample value pairs of each path of program, and sends the PCR/STC sample value pairs of each path of program to a system time management module; decoding the video and audio of the N paths of programs, and sending the decoded video and audio to a packet merging module;
the system time management module stores the PCR/STC sample value pairs of the N paths of programs in N paths of input queues, calculates and obtains the PCR '/STC sample value pairs in the corresponding output queues according to a preset mapping relation, and sends the obtained PCR'/STC sample value pairs in all the output queues to the coding module;
the grouping and combining module is used for recombining the decoded video and audio according to a preset recombination requirement to obtain at least one path of recombination result, and transmitting all the obtained recombination results to the coding module;
the coding module carries out coding compression on each path of video and audio after recombination, calculates PCR information of each path of output program according to the PCR '/STC' sample value in the corresponding output queue, carries out TS encapsulation on each path of video and audio corresponding to the coding compression according to the PCR information of each path of output program, obtains at least one path of output program stream, and sends all obtained output program streams to the multiplexing output module;
multiplexing the at least one output program stream into at least one TS stream by the multiplexing output module;
wherein N is more than or equal to 2.
2. The method of reorganizing a multi-channel TS stream program according to claim 1, wherein the decoding module further comprises, before sending the PCR/STC sample pairs for each channel of the program to a system time management module:
judging whether each PCR/STC sample value pair of each program is a discontinuous point or not through a discontinuous indication mark bit in the TS stream, and if the current sample value pair is the discontinuous point, adding a discontinuous point mark for the current sample value pair;
if the current sample pair is not a discontinuity, then adding a discontinuity identification to the current sample pair if the current sample pair satisfies the following formula:
|PCR 2 -PCR 1 |>|STC 2 -STC 1 |×G
wherein ,PCR2 /STC 2 For the current sample pair, PCR 1 /STC 1 G is a predetermined constant for the previous sample pair of the current sample pair.
3. The method of claim 2, wherein the encoding module calculates PCR information for each output program based on PCR '/STC' sample pairs in the corresponding output queues, and the method specifically comprises:
judging whether the PCR '/STC' sample value pair in the corresponding output queue is a continuous sample value pair according to the discontinuous point mark, and calculating the PCR information of each output program according to the following conditions for the continuous sample value pair:
if STC p Greater than the STC' of all sample pairs in the corresponding output queue, and PCR min ′/STC min ' continuous sample centering STC min ' and STC p The absolute difference between the STC ' and the PCR '/STC ' sample pair of the total output queue p The minimum value of the absolute value of the difference value of (2), the PCR information PCR of the current output program is calculated according to the following formula p
PCR p =PCR min ′+STC p -STC min ′;
If STC p Less than the STC' of all sample pairs in the corresponding output queue, and PCR min ′/STC min ' continuous sample centering STC min ' and STC p The absolute difference between the STC ' and the PCR '/STC ' sample pair of the total output queue p The minimum value of the absolute value of the difference value of (2), the PCR information PCR of the current output program is calculated according to the following formula p
PCR p =PCR min ′+STC min ′-STC p
If STC p First PCR in corresponding output queue 1 ′/STC 1 STC in' successive sample pairs 1 ' and second PCR 2 ′/STC 2 STC in' successive sample pairs 2 ' between them, the PCR information PCR of the current output program is calculated according to the following formula p
wherein ,STCp To output the current system time of the program.
4. The method for reorganizing a multi-channel TS stream program according to claim 1, wherein the decoding module decodes video and audio of the N-channel program, specifically includes:
respectively decoding the video and the audio of the N paths of programs according to a preset format;
respectively establishing a first annular cache and a second annular cache according to the video format and the audio format of each program;
detecting whether the residual spaces of the first annular cache and the second annular cache meet a preset space storage value or not respectively;
if the first annular cache meets the preset space storage value, storing the decoded video in the first annular cache;
if the second annular buffer meets the preset space storage value, storing the decoded audio in the second annular buffer;
otherwise, the decoded video and the video are put into a queuing queue until the first annular buffer or the second annular buffer meets the preset space storage value, and then the decoded video and the video are taken out from the queuing queue to be stored.
5. The method for reorganizing a multi-channel TS stream program according to claim 1, wherein the system time management module calculates PCR '/STC' sample pairs in corresponding output queues according to a preset mapping relationship, and specifically includes:
setting PCR integral time difference PCR of input program and output program recorded with mapping relation for every output queue offset
The PCR '/STC' sample pair in the corresponding output queue is calculated according to the following formula:
PCR′=PCR+PCR offset
STC′=STC。
6. the method for reorganizing a multi-channel TS stream program according to any one of claims 1 to 5, wherein the multiplexing output module multiplexes the at least one output program stream into at least one TS stream, specifically comprising:
calculating the transmission time required by each TS packet according to the total bit rate of the TS stream to be output and the total bit number of the standard TS packets;
respectively calculating the number of bits to be output by each output program in the single TS packet time according to the transmission time required by each TS packet;
calculating the total bit number of each output program according to the bit number of each output program to be output in the single TS packet time;
when the total bit number of any output program reaches the total bit number of the standard TS packet, one TS packet is taken out of the any output program according to the input sequence and is inserted into the TS stream to be output, and then the total bit number of the any output program is updated.
7. The method for reorganizing a multi-channel TS stream program as claimed in claim 6, further comprising:
when the total bit number of at least two paths of output programs reaches the total bit number of a standard TS packet, determining the priority order of each path of output programs according to the conflict times, the total bit rate of the TS stream to be output and the bit rate of each path of output programs, and selecting one path of output programs for output according to the priority order;
the output program which is not output is transferred to the next TS packet, so that the conflict times are increased, and the priority judgment is carried out again.
8. The method of reorganizing a multi-channel TS stream program as claimed in claim 7, wherein the priority order of each output program is judged according to the steps of:
if the conflicted output program contains PCR packets, setting the output program containing the PCR packets as the highest priority;
if TS packets to be inserted in the conflicting output programs are empty packets, discarding the empty packets;
if the conflicting output programs do not contain PCR packets and the TS packets to be inserted are not null packets, the priority of each output program is calculated according to the following formula:
wherein ,indicating priority of the nth output program at C time of conflict, bitRate n Bit rate, bitRate, representing the n-th output program T Representing the total bit rate of the TS stream to be output, C representing the number of collisions.
9. A storage medium having stored therein instructions which, when read by a computer, cause the computer to perform the method of reorganizing a multi-channel TS stream program as claimed in any one of claims 1 to 8.
10. A reorganizing apparatus for a multi-channel TS stream program, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the method of reorganizing a multi-channel TS stream program as claimed in any one of claims 1 to 8.
CN202110881665.8A 2021-08-02 2021-08-02 Method and device for reorganizing multi-channel TS (transport stream) programs Active CN113747209B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110881665.8A CN113747209B (en) 2021-08-02 2021-08-02 Method and device for reorganizing multi-channel TS (transport stream) programs

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110881665.8A CN113747209B (en) 2021-08-02 2021-08-02 Method and device for reorganizing multi-channel TS (transport stream) programs

Publications (2)

Publication Number Publication Date
CN113747209A CN113747209A (en) 2021-12-03
CN113747209B true CN113747209B (en) 2023-09-19

Family

ID=78729812

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110881665.8A Active CN113747209B (en) 2021-08-02 2021-08-02 Method and device for reorganizing multi-channel TS (transport stream) programs

Country Status (1)

Country Link
CN (1) CN113747209B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114203191B (en) * 2021-12-10 2022-09-09 河南广播电视台 Transmission method of DRA synchronous audio coding

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101426112A (en) * 2008-11-05 2009-05-06 青岛海信电子产业控股股份有限公司 Method and apparatus for television sound signal regulation
CN102196314A (en) * 2011-03-28 2011-09-21 苏州汉辰数字多媒体有限公司 System and method for realizing streaming media transmission by using peer-to-peer (P2P) set-top box
CN105323596A (en) * 2014-06-30 2016-02-10 惠州市伟乐科技股份有限公司 System and method for multi-data resynchronization in TS stream program
WO2017071670A1 (en) * 2015-10-30 2017-05-04 中兴通讯股份有限公司 Audio and video synchronization method, device and system
CN111263164A (en) * 2020-02-28 2020-06-09 中国电子科技集团公司第五十八研究所 High frame frequency video parallel coding and recombination method

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7735111B2 (en) * 2005-04-29 2010-06-08 The Directv Group, Inc. Merging of multiple encoded audio-video streams into one program with source clock frequency locked and encoder clock synchronized
US20080123732A1 (en) * 2006-11-27 2008-05-29 Rajesh Mamidwar Method and system for configuring decoding based on detecting transport stream input rate

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101426112A (en) * 2008-11-05 2009-05-06 青岛海信电子产业控股股份有限公司 Method and apparatus for television sound signal regulation
CN102196314A (en) * 2011-03-28 2011-09-21 苏州汉辰数字多媒体有限公司 System and method for realizing streaming media transmission by using peer-to-peer (P2P) set-top box
CN105323596A (en) * 2014-06-30 2016-02-10 惠州市伟乐科技股份有限公司 System and method for multi-data resynchronization in TS stream program
WO2017071670A1 (en) * 2015-10-30 2017-05-04 中兴通讯股份有限公司 Audio and video synchronization method, device and system
CN111263164A (en) * 2020-02-28 2020-06-09 中国电子科技集团公司第五十八研究所 High frame frequency video parallel coding and recombination method

Also Published As

Publication number Publication date
CN113747209A (en) 2021-12-03

Similar Documents

Publication Publication Date Title
US10827208B2 (en) Transmitting method, receiving method, transmitting device and receiving device
US10455260B2 (en) Transmitting method, receiving method, transmitting device, and receiving device
JP6040282B2 (en) Method and apparatus for decoding an enhanced video stream
US8503541B2 (en) Method and apparatus for determining timing information from a bit stream
US20200236410A1 (en) Transmitting device, receiving device, transmitting method and receiving method
US6542518B1 (en) Transport stream generating device and method, and program transmission device
US8483053B2 (en) Information processing device, information processing method, program, and data structure
US10327000B2 (en) Transmitting method for transmitting a plurality of packets including header information including divided data information and a value of an invalidated fragment counter
US11722714B2 (en) Transmitting method, receiving method, transmitting device and receiving device
US10075749B2 (en) Transport stream multiplexers and methods for providing packets on a transport stream
CN113747209B (en) Method and device for reorganizing multi-channel TS (transport stream) programs
US10506265B2 (en) Transmitting method, receiving method, transmitting device and receiving device
JP6957186B2 (en) Information processing equipment, information processing methods, programs, and recording medium manufacturing methods
US20130094594A1 (en) Method for configuring and transmitting m-unit
JP2005151463A (en) Device and method for receiving stream data
KR101290346B1 (en) System and method for contents multiplexing and streaming
JP2022064531A (en) Transmitting device and receiving device
JP2018137654A (en) Communication apparatus, communication program, and communication method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant