CN117156223B - Real-time stream switching method, device, electronic equipment and storage medium - Google Patents

Real-time stream switching method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117156223B
CN117156223B CN202311422611.0A CN202311422611A CN117156223B CN 117156223 B CN117156223 B CN 117156223B CN 202311422611 A CN202311422611 A CN 202311422611A CN 117156223 B CN117156223 B CN 117156223B
Authority
CN
China
Prior art keywords
time stamp
signal source
video
audio
key frame
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
CN202311422611.0A
Other languages
Chinese (zh)
Other versions
CN117156223A (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.)
China Media Group
Original Assignee
China Media Group
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 China Media Group filed Critical China Media Group
Priority to CN202311422611.0A priority Critical patent/CN117156223B/en
Publication of CN117156223A publication Critical patent/CN117156223A/en
Application granted granted Critical
Publication of CN117156223B publication Critical patent/CN117156223B/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/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/85Assembly of content; Generation of multimedia applications
    • H04N21/854Content authoring
    • H04N21/8547Content authoring involving timestamps for synchronizing content
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/65Network streaming protocols, e.g. real-time transport protocol [RTP] or real-time control protocol [RTCP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/70Media network packetisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/75Media network packet handling
    • H04L65/752Media network packet handling adapting media to network capabilities
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/80Responding to QoS

Abstract

The embodiment of the application provides a real-time stream switching method, a device, electronic equipment and a storage medium, which belong to the technical field of audio and video processing, and the method comprises the steps of obtaining at least one path of signal source, and obtaining video compression stream and audio compression stream corresponding to each path of signal source; obtaining a key frame of a signal source to be switched according to the video compression stream corresponding to the signal source to be switched; obtaining a video time stamp and an audio time stamp of the signal source to be switched according to the key frame; and switching signal sources according to the video time stamp and the audio time stamp. According to the embodiment of the application, the video compression stream corresponding to the signal source to be switched is analyzed, the key frame of the signal source to be switched is determined, the video time stamp and the audio time stamp corresponding to the switching point are recalculated, seamless smooth switching can be carried out at the switching point, mosaic or blocking phenomenon can not occur, an IP signal source is not required to be decoded into an SDI signal, and equipment cost is saved.

Description

Real-time stream switching method, device, electronic equipment and storage medium
Technical Field
The application relates to the technical field of audio and video processing, in particular to a real-time stream switching method, a device, electronic equipment and a storage medium.
Background
In the current broadcast and television industry, in order to ensure the broadcast safety, a broadcast system configures a plurality of input signal sources (main, standby and pad paths) for each output channel, and when the current input signal source is abnormal, a switching mechanism is triggered to switch the input signal source to another signal source. Switching of different signal sources is also common in some broadcast channel switching stations based on IP (Internet Protocol) input signal sources or switching according to channel ordering timing. Different signal sources based on the IP flow are switched, and two common implementation modes at present are as follows: one is an IP switch mode that directly hard switches the signal IP stream, which can cause the output stream to show decoded mosaics at the switch point, the timestamp of the output stream jumps, and the instability factor of the rear-end receiving system is increased; the other is a switching mode of an SDI (Serial Digital Interface, digital serial interface) switcher, signals are firstly decoded into an SDI format through a decoder, and then the signals are switched through the SDI switcher, so that the method can solve the technical defects of an IP switcher mode, but more decoding equipment and encoding equipment are needed, the performance requirements on equipment are very high, and the implementation cost is also very high.
Disclosure of Invention
In order to solve one of the technical defects, embodiments of the present application provide a method, an apparatus, an electronic device, and a storage medium for switching real-time streams.
According to a first aspect of an embodiment of the present application, there is provided a real-time stream switching method, including:
acquiring at least one path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source;
obtaining a key frame of a signal source to be switched according to the video compression stream corresponding to the signal source to be switched;
obtaining a video time stamp and an audio time stamp of the signal source to be switched according to the key frame;
and switching signal sources according to the video time stamp and the audio time stamp.
As an embodiment, the obtaining at least one signal source to obtain a video compressed stream and an audio compressed stream corresponding to each signal source includes:
acquiring at least one signal source;
and carrying out analysis processing and stripping processing on the container layer of each path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source.
As an embodiment, the obtaining the key frame of the signal source to be switched according to the video compression stream corresponding to the signal source to be switched includes:
analyzing the video compression stream corresponding to the signal source to be switched based on a video coding and decoding protocol corresponding to the video compression stream, and determining a target identifier;
and obtaining the key frame of the signal source to be switched according to the target identifier.
As an embodiment, the obtaining, according to the key frame, a video time stamp and an audio time stamp of the signal source to be switched includes:
and respectively obtaining the video time stamp and the audio time stamp of the signal source to be switched according to the key frame time stamp corresponding to the key frame.
As an embodiment, according to the key frame timestamp corresponding to the key frame, obtaining the video timestamp of the signal source to be switched includes:
substituting the key frame time stamp corresponding to the key frame into a video time stamp calculation formula to obtain the video time stamp of the signal source to be switched;
the video timestamp calculation formula is as follows:
T_V=T_oldlast + (T_Vnew–T_Vnewstart);
wherein t_v is a video time stamp, t_oldlast is a last time stamp before switching, t_vnew is a video compressed stream time stamp after switching, and t_vnewstart is a key frame time stamp.
As an embodiment, according to the key frame timestamp corresponding to the key frame, obtaining the audio timestamp of the signal source to be switched includes:
substituting the key frame time stamp corresponding to the key frame into an audio time stamp calculation formula to obtain the audio time stamp of the signal source to be switched;
the audio time stamp calculation formula is as follows:
T_A= T_oldlast + (T_Anew – T_Vnewstart);
t_a is the audio timestamp, t_oldlast is the last timestamp before the switch, t_anew is the post-switch audio compressed stream timestamp, and t_vnewstart is the key frame timestamp.
As one embodiment, the switching of signal sources according to the video time stamp and the audio time stamp includes:
determining a first output starting point of the video compression stream of the signal source to be switched and a second output starting point of the audio compression stream of the signal source to be switched according to the key frame;
and packaging the video compression stream after the first output starting point, the audio compression stream after the second output starting point, the video time stamp and the audio time stamp to obtain a signal source to be output, and finishing signal source switching.
According to a second aspect of the embodiments of the present application, there is provided a real-time stream switching apparatus, including:
the acquisition module is used for acquiring at least one path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source;
the key frame determining module is used for obtaining a key frame of the signal source to be switched according to the video compression stream corresponding to the signal source to be switched;
the time stamp determining module is used for obtaining a time stamp corresponding to the key frame according to the audio compression stream corresponding to the signal source to be switched;
and the switching module is used for switching signal sources according to the time stamp.
By adopting the real-time stream switching method, the device, the electronic equipment and the storage medium provided by the embodiment of the application, at least one path of signal source is obtained, and video compression stream and audio compression stream corresponding to each path of signal source are obtained; obtaining a key frame of a signal source to be switched according to the video compression stream corresponding to the signal source to be switched; obtaining a video time stamp and an audio time stamp of the signal source to be switched according to the key frame; and switching signal sources according to the video time stamp and the audio time stamp. According to the embodiment of the application, the video compression stream corresponding to the signal source to be switched is analyzed, the key frame of the signal source to be switched is determined, the video time stamp and the audio time stamp corresponding to the switching point are recalculated, seamless smooth switching can be carried out at the switching point, mosaic or blocking phenomenon can not occur, an IP signal source is not required to be decoded into an SDI signal, and equipment cost is saved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
fig. 1 is a flow chart of a real-time stream switching method according to an embodiment of the present application;
fig. 2 is a schematic flow chart of signal source demultiplexing according to an embodiment of the present application;
fig. 3 is a schematic flowchart of step S120 in fig. 1 according to an embodiment of the present application;
fig. 4 is a schematic diagram of a signal source switching flow provided in an embodiment of the present application;
fig. 5 is a schematic flowchart of step S140 in fig. 1 according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a real-time stream switching device according to an embodiment of the present application;
FIG. 7 is a second schematic structural diagram of a real-time stream switching device according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions and advantages of the embodiments of the present application more apparent, the following detailed description of exemplary embodiments of the present application is given with reference to the accompanying drawings, and it is apparent that the described embodiments are only some of the embodiments of the present application and not exhaustive of all the embodiments. It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other.
Fig. 1 is a flow chart of a real-time stream switching method provided in an embodiment of the present application, as shown in fig. 1, where the embodiment of the present application provides a real-time stream switching method, which is implemented based on a multiplexing switcher (Mux), and includes:
s110, acquiring at least one path of signal source to obtain a video compression stream and an audio compression stream corresponding to each path of signal source;
s120, obtaining a key frame of the signal source to be switched according to the video compression stream corresponding to the signal source to be switched;
s130, obtaining a video time stamp and an audio time stamp of the signal source to be switched according to the key frame;
and S140, switching signal sources according to the video time stamp and the audio time stamp.
The signal source in step S110 may be a high-definition or ultra-high-definition audio/video IP stream, such as a 4k AVS2 audio/video IP stream or an 8k AVS3 audio/video IP stream. The embodiment of the application takes 8K AVS3 audio/video IP stream as an example for illustration.
If a switching instruction is received, a signal source to be switched can be determined from the switching instruction, before the signal source to be switched replaces the current output signal source, a key frame of a video compression stream of the signal source to be switched can be determined based on a video key frame retrieval technology, then a video time stamp and an audio time stamp of the signal source to be switched are determined according to the key frame, time stamp jump is avoided, finally the signal source to be switched is packaged and output according to the video time stamp and the audio time stamp, and signal source switching is completed.
Specifically, the multiplex switcher includes three modules inside: the system comprises a de-multiplexing stream module, a stream switching module and a multiplexing stream module. The multiplexing switcher demultiplexes each IP signal source, strips the file encapsulation layer (typically TS file layer) and separates the video compression stream and the audio compression stream, when the signal source is switched, firstly analyzes the video compression code stream of the signal source to be switched, and needs to find the position of a key frame (a GOP beginning) of the video compression code stream of the signal source to be switched in order to ensure the decoding quality of a back-end system (picture is free of mosaic), and needs to recalculate the audio and video time stamp of the new output stream at the switching point in order to ensure the seamless smooth switching of the switching point to the new output stream, and finally reuses the audio and video compression data of the switched audio and video compression stream according to the calculated time stamp (typically TS file encapsulation layer).
It can be understood that, in the embodiment of the present application, by analyzing the video compression stream corresponding to the signal source to be switched, determining the key frame of the signal source to be switched, and recalculate the video timestamp and the audio timestamp corresponding to the switching point, it is ensured that seamless smooth switching can be performed at the switching point, no mosaic or blocking phenomenon occurs, no need of decoding the IP signal source into the SDI signal, and saving the equipment cost.
Fig. 2 is a schematic flow chart of demultiplexing a signal source provided in an embodiment of the present application, as shown in fig. 2, as an embodiment, the obtaining at least one path of signal source, to obtain a video compression stream and an audio compression stream corresponding to each path of signal source includes:
acquiring at least one signal source; and carrying out analysis processing and stripping processing on the container layer of each path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source.
In particular, parsing the video compression stream and the audio compression stream from the signal source is implemented based on a demultiplexing stream module of the multiplexing switch. Each signal source firstly analyzes a signal source file encapsulation layer (generally referred to as TS file encapsulation) through a respective demultiplexing module, then peels off a file multiplexing layer (generally referred to as TS file encapsulation) of a signal source code stream, separates an original interleaved audio and video code stream from an independent AVS3 original coded compressed data stream and an audio coded compressed data stream.
Optionally, the number of the demultiplexing modules corresponds to the number of input paths of the signal source, and specifically, the demultiplexing modules with the number of redundant input paths of the signal source can also be set, so that a redundancy function is realized, and the efficiency is improved.
It can be understood that in the embodiment of the application, the container layer of the signal source is analyzed, encoding and decoding of video stream data and audio stream data are not needed, a link is relatively simple to construct, the load is low, and the equipment consumption is greatly saved.
Fig. 3 is a schematic flow chart of step S120 in fig. 1 provided in the embodiment of the present application, and fig. 4 is a schematic flow chart of signal source switching provided in the embodiment of the present application, as shown in fig. 3 and fig. 4, as an embodiment, the obtaining, according to the video compression stream corresponding to the signal source to be switched, a key frame of the signal source to be switched includes:
s310, analyzing the video compression stream corresponding to the signal source to be switched based on a video coding and decoding protocol corresponding to the video compression stream, and determining a target identifier; the target identifier is an intra-prediction image start code.
And S320, obtaining the key frame of the signal source to be switched according to the target identifier.
Specifically, step S310 and step S320 are implemented based on a switching stream module of the multiplexing switcher, and different signal sources output separate AVS3 encoded compressed streams and audio encoded compressed streams through a demultiplexing module and simultaneously input into the switching stream module. When the switching stream occurs, the switching stream module firstly analyzes AVS3 video compression stream data to be switched, searches the nearest key frame position, recalculates the timestamp of audio and video data output of the stream to be switched, and finally switches to a new audio and video output stream.
In step S310 and step S320, the AVS3 video compression stream is analyzed, the "0x000001B3" intra-prediction picture start code is found according to the AVS3 standard definition, and the key frame location and the corresponding timestamp t_vnewstart are recorded, the AVS3 standard definition table is as follows:
start code type Initial code value (hexadecimal)
Slice start code (patch_start_code) 00~7F
Reservation of 80~8E
Chip end code (latch_end_code) 8F
Reservation of 90~AF
Video sequence start code (video sequence start code) B0
Video sequence end code (video_sequence_end_code) B1
User data start code (user_data_start_code) B2
Intra prediction picture start code (intra_picture_start_code) B3
Reservation of B4
Video extension start code (extension_start_code) B5
Inter predicted picture start code (inter picture start code) B6
Video editing code (video_edit_code) B7
Reservation of B8
System start code B9~FF
It can be understood that, in the embodiment of the present application, the location of the key frame can be easily defined by searching the target identifier in the video compression stream, and the content of the audio compression stream is not required to be parsed, so that the link is relatively simple to construct, and the load is low.
As an embodiment, the obtaining, according to the key frame, a video time stamp and an audio time stamp of the signal source to be switched includes:
and respectively obtaining the video time stamp and the audio time stamp of the signal source to be switched according to the key frame time stamp corresponding to the key frame.
Optionally, obtaining the video timestamp of the signal source to be switched according to the key frame timestamp corresponding to the key frame includes:
substituting the key frame time stamp corresponding to the key frame into a video time stamp calculation formula to obtain the video time stamp of the signal source to be switched;
the video timestamp calculation formula is as follows:
T_V=T_oldlast + (T_Vnew–T_Vnewstart);
wherein t_v is a video time stamp, t_oldlast is a last time stamp before switching, t_vnew is a video compressed stream time stamp after switching, and t_vnewstart is a key frame time stamp.
Optionally, obtaining the audio time stamp of the signal source to be switched according to the key frame time stamp corresponding to the key frame includes:
substituting the key frame time stamp corresponding to the key frame into an audio time stamp calculation formula to obtain the audio time stamp of the signal source to be switched;
the audio time stamp calculation formula is as follows:
T_A= T_oldlast + (T_Anew – T_Vnewstart);
t_a is the audio timestamp, t_oldlast is the last timestamp before the switch, t_anew is the post-switch audio compressed stream timestamp, and t_vnewstart is the key frame timestamp.
It can be understood that, in the embodiment of the application, by recalculating the audio and video time stamp of the new output stream, the continuity of the whole output stream (the output stream before and after switching is consistent) can be maintained, so that the non-sensing front-end signal source switching of the back-end system is realized.
Fig. 5 is a schematic flowchart of step S140 in fig. 1 provided in the embodiment of the present application, as shown in fig. 5, as an embodiment, the switching of signal sources according to the video timestamp and the audio timestamp includes:
s510, determining a first output starting point of the video compression stream of the signal source to be switched and a second output starting point of the audio compression stream of the signal source to be switched according to the key frame;
s520, packaging the video compression stream after the first output starting point, the audio compression stream after the second output starting point, the video time stamp and the audio time stamp to obtain a signal source to be output, and finishing signal source switching.
Specifically, step S510 and step S520 are implemented based on a multiplexing stream module of the multiplexing switcher, and the signal source AVS3 video compression stream to be switched starts from the key frame position and outputs the video compression stream.
Specifically, in step S520, the switched AVS3 compressed data stream and audio compressed data stream are subjected to file encapsulation layer multiplexing (generally referred to as TS file encapsulation layer).
It can be appreciated that since the video compression data after switching starts from the key frame and the audio and video compression stream time stamps are continuously switched to the audio and video compression stream time stamps, there is almost no sense of front-end signal source switching to the back-end receiving system. Compared with the switching scheme of the IP switcher, the switching method has the advantages of smoothness in switching, no mosaic and no blocking, and the switching quality is greatly improved; compared with the switching scheme of the SDI switcher, the method has the advantages of relatively simple link construction, low load and great equipment consumption saving due to the reduction of links of AVS3 code stream decoding and AVS3 code stream coding.
The real-time stream switching device provided by the invention is described below, and the real-time stream switching device described below and the real-time stream switching method described above can be referred to correspondingly.
Fig. 6 is a schematic structural diagram of a real-time flow switching device provided in an embodiment of the present application, and as shown in fig. 6, the embodiment of the present application further provides a real-time flow switching device, including:
the obtaining module 610 is configured to obtain at least one signal source, and obtain a video compressed stream and an audio compressed stream corresponding to each signal source;
a key frame determining module 620, configured to obtain a key frame of the signal source to be switched according to the video compression stream corresponding to the signal source to be switched;
the timestamp determining module 630 is configured to obtain a timestamp corresponding to the key frame according to the audio compressed stream corresponding to the signal source to be switched;
and the switching module 640 is used for switching signal sources according to the time stamp.
As an embodiment, the obtaining module 610 is further configured to:
acquiring at least one signal source;
and carrying out analysis processing and stripping processing on the container layer of each path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source.
For one embodiment, the key frame determination module 620 is further configured to:
analyzing the video compression stream corresponding to the signal source to be switched based on a video coding and decoding protocol corresponding to the video compression stream, and determining a target identifier;
and obtaining the key frame of the signal source to be switched according to the target identifier.
As an embodiment, the timestamp determining module 630 is further configured to:
and respectively obtaining the video time stamp and the audio time stamp of the signal source to be switched according to the key frame time stamp corresponding to the key frame.
As an embodiment, the timestamp determining module 630 is further configured to:
substituting the key frame time stamp corresponding to the key frame into a video time stamp calculation formula to obtain the video time stamp of the signal source to be switched;
the video timestamp calculation formula is as follows:
T_V=T_oldlast + (T_Vnew–T_Vnewstart);
wherein t_v is a video time stamp, t_oldlast is a last time stamp before switching, t_vnew is a video compressed stream time stamp after switching, and t_vnewstart is a key frame time stamp.
As an embodiment, the timestamp determining module 630 is further configured to:
substituting the key frame time stamp corresponding to the key frame into an audio time stamp calculation formula to obtain the audio time stamp of the signal source to be switched;
the audio time stamp calculation formula is as follows:
T_A= T_oldlast + (T_Anew – T_Vnewstart);
t_a is the audio timestamp, t_oldlast is the last timestamp before the switch, t_anew is the post-switch audio compressed stream timestamp, and t_vnewstart is the key frame timestamp.
As an embodiment, the switching module 640 is further configured to:
determining a first output starting point of the video compression stream of the signal source to be switched and a second output starting point of the audio compression stream of the signal source to be switched according to the key frame;
and packaging the video compression stream after the first output starting point, the audio compression stream after the second output starting point, the video time stamp and the audio time stamp to obtain a signal source to be output, and finishing signal source switching.
Fig. 7 is a second schematic structural diagram of a real-time stream switching device according to an embodiment of the present application, as shown in fig. 7, where the embodiment of the present application provides a real-time stream switching device that uses Mux (multiplexing switcher) logic to search based on video key frames.
The multiplexing switch internally comprises three modules: the system comprises a de-multiplexing stream module, a stream switching module and a multiplexing stream module. The multiplexing switcher demultiplexes each IP signal source, strips the file encapsulation layer (typically TS file layer) and separates the video compression stream and the audio compression stream, when the signal source is switched, firstly analyzes the video compression code stream of the signal source to be switched, and needs to find the position of a key frame (a GOP beginning) of the video compression code stream of the signal source to be switched in order to ensure the decoding quality of a back-end system (picture is free of mosaic), and needs to recalculate the audio and video time stamp of the new output stream at the switching point in order to ensure the seamless smooth switching of the switching point to the new output stream, and finally reuses the audio and video compression data of the switched audio and video compression stream according to the calculated time stamp (typically TS file encapsulation layer).
The method and the device provided by the embodiment of the application can be integrated in the 8K AVS3 integrated IP broadcasting server, so that the output quality of the 8K AVS3 stream switching link is improved, and because the equipment resource consumption required by the embodiment of the application is relatively small, the seamless switching between 8K AVS3 real-time streams can be realized through a single machine, the investment of corresponding equipment resources is greatly reduced, and the real-time safe switching of the whole 8K AVS3 carousel channel is ensured.
Fig. 8 illustrates a physical structure diagram of an electronic device, as shown in fig. 8, which may include: processor 810, communication interface (Communications Interface) 820, memory 830, and communication bus 840, wherein processor 810, communication interface 820, memory 830 accomplish communication with each other through communication bus 840. The processor 810 may invoke logic instructions in the memory 830 to perform a real-time stream switching method comprising:
acquiring at least one path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source;
obtaining a key frame of a signal source to be switched according to the video compression stream corresponding to the signal source to be switched;
obtaining a video time stamp and an audio time stamp of the signal source to be switched according to the key frame;
and switching signal sources according to the video time stamp and the audio time stamp.
Further, the logic instructions in the memory 830 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, 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, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, the computer program product comprising a computer program, the computer program being storable on a non-transitory computer readable storage medium, the computer program, when executed by a processor, being capable of executing the real-time stream switching method provided by the above methods, the method comprising:
acquiring at least one path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source;
obtaining a key frame of a signal source to be switched according to the video compression stream corresponding to the signal source to be switched;
obtaining a video time stamp and an audio time stamp of the signal source to be switched according to the key frame;
and switching signal sources according to the video time stamp and the audio time stamp.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the real-time stream switching method provided by the above methods, the method comprising:
acquiring at least one path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source;
obtaining a key frame of a signal source to be switched according to the video compression stream corresponding to the signal source to be switched;
obtaining a video time stamp and an audio time stamp of the signal source to be switched according to the key frame;
and switching signal sources according to the video time stamp and the audio time stamp.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein. The schemes in the embodiments of the present application may be implemented in various computer languages, for example, C language, VHDL language, verilog language, object-oriented programming language Java, and transliteration scripting language JavaScript, etc.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In the description of the present application, it should be understood that the terms "center," "longitudinal," "transverse," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," and the like indicate an orientation or positional relationship based on that shown in the drawings, merely for convenience of description and to simplify the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be configured and operated in a particular orientation, and thus should not be construed as limiting the present application.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. In the description of the present application, the meaning of "plurality" is at least two, such as two, three, etc., unless explicitly defined otherwise.
In this application, unless specifically stated and limited otherwise, the terms "mounted," "connected," "secured," and the like are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally formed; may be mechanically connected, may be electrically connected or may communicate with each other; can be directly connected or indirectly connected through an intermediate medium, and can be communicated with the inside of two elements or the interaction relationship of the two elements. The specific meaning of the terms in this application will be understood by those of ordinary skill in the art as the case may be.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to cover such modifications and variations.

Claims (7)

1. A real-time stream switching method, comprising:
when a switching instruction is received, determining a signal source to be switched from the switching instruction; before replacing the signal source to be switched with the current output signal source, the following steps are carried out:
acquiring at least one path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source;
obtaining a key frame of a signal source to be switched according to the video compression stream corresponding to the signal source to be switched;
according to the key frame, recalculating a video time stamp and an audio time stamp corresponding to the switching point to obtain the video time stamp and the audio time stamp of the signal source to be switched;
switching signal sources according to the video time stamp and the audio time stamp, and performing seamless smooth switching at a switching point;
and obtaining the video time stamp and the audio time stamp of the signal source to be switched according to the key frame, wherein the method comprises the following steps:
respectively obtaining a video time stamp and an audio time stamp of the signal source to be switched according to the key frame time stamp corresponding to the key frame;
obtaining the video time stamp of the signal source to be switched according to the key frame time stamp corresponding to the key frame, including:
substituting the key frame time stamp corresponding to the key frame into a video time stamp calculation formula to obtain the video time stamp of the signal source to be switched;
the video timestamp calculation formula is as follows:
T_V=T_oldlast + (T_Vnew–T_Vnewstart);
wherein, t_v is a video time stamp, t_oldlast is a last time stamp before switching, t_vnew is a video compressed stream time stamp after switching, and t_vnewstart is a key frame time stamp;
obtaining the audio time stamp of the signal source to be switched according to the key frame time stamp corresponding to the key frame, including:
substituting the key frame time stamp corresponding to the key frame into an audio time stamp calculation formula to obtain the audio time stamp of the signal source to be switched;
the audio time stamp calculation formula is as follows:
T_A= T_oldlast + (T_Anew – T_Vnewstart);
T_A is an audio time stamp, T_oldlast is the last time stamp before switching, T_Anew is an audio compressed stream time stamp after switching, and T_Vnewstart is a key frame time stamp;
s510, determining a first output starting point of the video compression stream of the signal source to be switched and a second output starting point of the audio compression stream of the signal source to be switched according to the key frame;
s520, packaging the video compression stream after the first output starting point, the audio compression stream after the second output starting point, the video time stamp and the audio time stamp to obtain a signal source to be output, and finishing signal source switching.
2. The method for switching real-time streams according to claim 1, wherein said obtaining at least one signal source to obtain a video compression stream and an audio compression stream corresponding to each signal source comprises:
acquiring at least one signal source;
and carrying out analysis processing and stripping processing on the container layer of each path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source.
3. The method for switching real-time streams according to claim 1, wherein the obtaining key frames of the signal source to be switched according to the video compressed stream corresponding to the signal source to be switched includes:
analyzing the video compression stream corresponding to the signal source to be switched based on a video coding and decoding protocol corresponding to the video compression stream, and determining a target identifier;
and obtaining the key frame of the signal source to be switched according to the target identifier.
4. The real-time stream switching method according to claim 1, wherein said switching signal sources according to the video time stamp and the audio time stamp comprises:
determining a first output starting point of the video compression stream of the signal source to be switched and a second output starting point of the audio compression stream of the signal source to be switched according to the key frame;
and packaging the video compression stream after the first output starting point, the audio compression stream after the second output starting point, the video time stamp and the audio time stamp to obtain a signal source to be output, and finishing signal source switching.
5. A real-time stream switching apparatus, comprising:
the triggering module is used for determining a signal source to be switched from the switching instruction when the switching instruction is received; triggering the real-time stream switching device to work before the signal source to be switched replaces the current output signal source;
the acquisition module is used for acquiring at least one path of signal source to obtain video compression stream and audio compression stream corresponding to each path of signal source;
the key frame determining module is used for obtaining key frames of the signal source to be switched according to the video compression stream corresponding to the signal source to be switched;
the time stamp determining module is used for recalculating the video time stamp and the audio time stamp corresponding to the switching point according to the audio compression stream corresponding to the signal source to be switched to obtain the time stamp corresponding to the key frame;
the switching module is used for switching signal sources according to the time stamp and performing seamless smooth switching at a switching point;
recalculating the video time stamp and the audio time stamp corresponding to the switching point, comprising:
respectively obtaining a video time stamp and an audio time stamp of a signal source to be switched according to the key frame time stamp corresponding to the key frame;
obtaining a video time stamp of the signal source to be switched according to the key frame time stamp corresponding to the key frame, comprising:
substituting the key frame time stamp corresponding to the key frame into a video time stamp calculation formula to obtain a video time stamp of the signal source to be switched;
the video timestamp calculation formula is as follows:
T_V=T_oldlast + (T_Vnew–T_Vnewstart);
wherein, t_v is a video time stamp, t_oldlast is a last time stamp before switching, t_vnew is a video compressed stream time stamp after switching, and t_vnewstart is a key frame time stamp;
obtaining an audio time stamp of the signal source to be switched according to the key frame time stamp corresponding to the key frame, wherein the audio time stamp comprises:
substituting the key frame time stamp corresponding to the key frame into an audio time stamp calculation formula to obtain the audio time stamp of the signal source to be switched;
the audio time stamp calculation formula is as follows:
T_A= T_oldlast + (T_Anew – T_Vnewstart);
T_A is an audio time stamp, T_oldlast is the last time stamp before switching, T_Anew is an audio compressed stream time stamp after switching, and T_Vnewstart is a key frame time stamp;
determining a first output starting point of the video compression stream of the signal source to be switched and a second output starting point of the audio compression stream of the signal source to be switched according to the key frame;
and packaging the video compression stream after the first output starting point, the audio compression stream after the second output starting point, the video time stamp and the audio time stamp to obtain a signal source to be output, and finishing signal source switching.
6. An electronic device, comprising:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of any of claims 1-5.
7. A computer-readable storage medium, characterized in that a computer program is stored thereon; the computer program being executed by a processor to implement the method of any of claims 1-5.
CN202311422611.0A 2023-10-31 2023-10-31 Real-time stream switching method, device, electronic equipment and storage medium Active CN117156223B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311422611.0A CN117156223B (en) 2023-10-31 2023-10-31 Real-time stream switching method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311422611.0A CN117156223B (en) 2023-10-31 2023-10-31 Real-time stream switching method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117156223A CN117156223A (en) 2023-12-01
CN117156223B true CN117156223B (en) 2024-03-15

Family

ID=88906566

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311422611.0A Active CN117156223B (en) 2023-10-31 2023-10-31 Real-time stream switching method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117156223B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101854533A (en) * 2010-06-10 2010-10-06 华为技术有限公司 Frequency channel switching method, device and system
CN103313125A (en) * 2013-05-03 2013-09-18 上海东方明珠广播电视研究发展有限公司 Transport stream-based duplex digital television signal seamless switching method and system
CN103475900A (en) * 2012-06-06 2013-12-25 中国移动通信集团公司 Method and device for packaging mobile phone television service video frame and front-end system
WO2014009450A1 (en) * 2012-07-13 2014-01-16 Broadpeak Method and device for allowing seamlessly switching from one layer to another in a conditional access system context
CN109168078A (en) * 2018-09-10 2019-01-08 苏宁智能终端有限公司 A kind of video definition switching method and device
CN109246462A (en) * 2018-10-11 2019-01-18 苏宁易购集团股份有限公司 A kind of video flowing seamless handover method and device
CN111918096A (en) * 2020-07-21 2020-11-10 上海网达软件股份有限公司 Method, device and equipment for fast switching input source of cloud director and storage medium
CN116886973A (en) * 2023-07-13 2023-10-13 广东保伦电子股份有限公司 Fast switching equipment and method based on H.264 and H.265 video multicast code streams

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002007440A2 (en) * 2000-07-15 2002-01-24 Filippo Costanzo Audio-video data switching and viewing system
US9131271B2 (en) * 2011-11-02 2015-09-08 Connected Lyfe Systems and methods for real-time adaptation of multimedia data
CN105191316A (en) * 2013-03-15 2015-12-23 罗伯特·博世有限公司 Switching apparatus for switching compressed video streams, conference system with the switching apparatus and process for switching compressed video streams

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101854533A (en) * 2010-06-10 2010-10-06 华为技术有限公司 Frequency channel switching method, device and system
CN103475900A (en) * 2012-06-06 2013-12-25 中国移动通信集团公司 Method and device for packaging mobile phone television service video frame and front-end system
WO2014009450A1 (en) * 2012-07-13 2014-01-16 Broadpeak Method and device for allowing seamlessly switching from one layer to another in a conditional access system context
CN103313125A (en) * 2013-05-03 2013-09-18 上海东方明珠广播电视研究发展有限公司 Transport stream-based duplex digital television signal seamless switching method and system
CN109168078A (en) * 2018-09-10 2019-01-08 苏宁智能终端有限公司 A kind of video definition switching method and device
CN109246462A (en) * 2018-10-11 2019-01-18 苏宁易购集团股份有限公司 A kind of video flowing seamless handover method and device
CN111918096A (en) * 2020-07-21 2020-11-10 上海网达软件股份有限公司 Method, device and equipment for fast switching input source of cloud director and storage medium
CN116886973A (en) * 2023-07-13 2023-10-13 广东保伦电子股份有限公司 Fast switching equipment and method based on H.264 and H.265 video multicast code streams

Also Published As

Publication number Publication date
CN117156223A (en) 2023-12-01

Similar Documents

Publication Publication Date Title
US11632572B2 (en) Image coding method, image decoding method, image coding apparatus, image decoding apparatus, and image coding and decoding apparatus
CA2193109C (en) Video compression using a signal transmission chain comprising an information bus linking encoders and decoders
CN103024444B (en) For the system and method that channel switches
AU2016202208B2 (en) Coding concept allowing parallel processing, transport demultiplexer and video bitstream
CN103843342B (en) Image decoding method
CN101682762B (en) Method for realizing random access in compressed code stream using multi-reference images and decoder
CA2533221A1 (en) Video compression using a signal transmission chain comprising an information bus linking encoders and decoders
KR100773304B1 (en) Encoder and encoding method
CN105025303A (en) Decoding and encoding of pictures of a video sequence
CN102630382B (en) Digital broadcast reception device, and channel changing method
CN117156223B (en) Real-time stream switching method, device, electronic equipment and storage medium
US20150139338A1 (en) Identifying Leading Pictures in Video Coding
US20100166383A1 (en) System and method for providing trick modes
AU3798199A (en) Video compression

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