CN110891051B - Streaming media live broadcast method and device and computer readable storage medium - Google Patents

Streaming media live broadcast method and device and computer readable storage medium Download PDF

Info

Publication number
CN110891051B
CN110891051B CN201911039660.XA CN201911039660A CN110891051B CN 110891051 B CN110891051 B CN 110891051B CN 201911039660 A CN201911039660 A CN 201911039660A CN 110891051 B CN110891051 B CN 110891051B
Authority
CN
China
Prior art keywords
source
source address
rtsp
rtmp
streaming media
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
CN201911039660.XA
Other languages
Chinese (zh)
Other versions
CN110891051A (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.)
Visionvera Information Technology Co Ltd
Original Assignee
Visionvera Information Technology 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 Visionvera Information Technology Co Ltd filed Critical Visionvera Information Technology Co Ltd
Priority to CN201911039660.XA priority Critical patent/CN110891051B/en
Publication of CN110891051A publication Critical patent/CN110891051A/en
Application granted granted Critical
Publication of CN110891051B publication Critical patent/CN110891051B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • 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
    • 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/47End-user applications
    • H04N21/478Supplemental services, e.g. displaying phone caller identification, shopping application
    • H04N21/4782Web browsing, e.g. WebTV

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a method and a device for playing live streaming media and a computer readable storage medium, wherein the method comprises the following steps: acquiring a rtmp source of a streaming media live broadcast to be played, calling a first conversion service, converting the rtmp source into a target source, wherein the target source is a live broadcast source supported by the browser to be played, and playing the streaming media live broadcast corresponding to the target source. By adopting the streaming media live broadcast method, the rtmp source of the streaming media live broadcast to be played is acquired, the first conversion service is called, and the rtmp source is directly converted into the target source.

Description

Streaming media live broadcast method and device and computer readable storage medium
Technical Field
The present invention relates to the field of video playing technologies, and in particular, to a method and an apparatus for playing a live streaming media, and a computer-readable storage medium.
Background
With the development of internet technology and streaming media technology, more and more people are used to play streaming media live broadcast through a web browser, and the playing of the streaming media live broadcast through the web browser has the advantages of convenience, rapidness, no need of downloading a whole live broadcast content file before playing and the like.
Playing Streaming media live broadcast through a web browser needs to provide a live broadcast source address of the Streaming media live broadcast, and generally, the live broadcast source address of the Streaming media live broadcast includes a live broadcast source address in an rtsp (Real Time Streaming Protocol) format or a live broadcast source address in an rtmp (Real Time Messaging Protocol) format.
Disclosure of Invention
In view of the above problems, embodiments of the present invention are provided to provide a method, an apparatus, and a computer-readable storage medium for playing a live streaming media, which overcome the above problems or at least partially solve the above problems.
In order to solve the above problem, an embodiment of the present invention discloses a streaming media live broadcast method, which is applied to a browser, and the method includes:
acquiring a rtmp source for live broadcasting of streaming media to be played;
calling a first conversion service, and converting the rtmp source into a target source, wherein the target source is a live source which is supported by the browser to play;
and playing the streaming media live broadcast corresponding to the target source.
Optionally, before the obtaining of the rtmp source of the streaming media to be played, the method further includes:
calling a live broadcast service interface of the streaming media according to the live broadcast identification of the live broadcast of the streaming media to be played, and judging whether an rtsp source of the live broadcast of the streaming media to be played can be acquired;
starting a conversion process under the condition that the rtsp source can be obtained;
the acquiring the rtmp source of the streaming media to be played comprises:
and acquiring the rtmp source by utilizing the conversion process.
Optionally, a static dictionary is established in the streaming media live broadcast service, where the static dictionary is used to store an association relationship between an rtsp source address corresponding to an rtsp source and a target source address corresponding to a target source, and the obtaining the rtmp source by using the conversion process includes:
inquiring whether the static dictionary stores the incidence relation between the rtsp source address and the target source address or not;
and under the condition that the incidence relation between the rtsp source address and the target source address is stored in the static dictionary, directly acquiring the rtmp source.
Optionally, after whether the association relationship between the rtsp source address and the target source address is stored in the query static dictionary, the method further includes:
under the condition that the incidence relation between the rtsp source address and the target source address is not stored in the static dictionary, calling a second conversion service to convert the rtsp source into the rtmp source and simultaneously returning the target source address;
and acquiring the rtmp source and the target source address after conversion.
Optionally, after the obtaining the converted rtmp source and the target source address, the method further includes:
establishing an incidence relation between an rtsp source address corresponding to the rtsp source and a target source address corresponding to the target source;
adding the incidence relation between the rtsp source address and the target source address into the static dictionary;
and when the rtsp source is obtained again, inquiring the association relation between the rtsp source address corresponding to the rtsp source and the target source address from the static dictionary, and directly obtaining the rtmp source.
Optionally, after the initiating the conversion process, the method further comprises:
under the condition that the rtmp source cannot be obtained by utilizing the conversion process, quitting the conversion process, and inquiring whether a static dictionary stores the incidence relation between the rtmp source address and the target source address;
and under the condition that the static dictionary is inquired to store the incidence relation between the rtsp source address and the target source address, deleting the incidence relation between the rtsp source address and the target source address from the static dictionary.
Optionally, the method further comprises:
periodically judging whether the incidence relation between the rtsp source address and the target source address stored in the static dictionary is available, wherein the incidence relation between the rtsp source address and the target source address is unavailable when the rtsp source corresponding to the rtsp source address does not exist;
and under the condition that the incidence relation between the rtsp source address and the target source address stored in the static dictionary is unavailable, deleting the incidence relation between the rtsp source address and the target source address from the static dictionary.
Optionally, after determining whether an rtsp source for acquiring a live broadcast of the to-be-played streaming media can be acquired, the method further includes:
and returning an error prompt under the condition that an rtsp source for the live broadcast of the streaming media to be played cannot be acquired.
Optionally, the converting the rtmp source into the target source includes:
when the browser is applied to a PC or an Android platform, the rtmp source is converted into a websocket source;
when the browser is applied to the iOS platform, the rtmp source is converted into an m3u8 source.
The embodiment of the invention also discloses a streaming media live broadcast device, which comprises:
the acquisition module is used for acquiring a rtmp source for live broadcasting of streaming media to be played;
the first conversion module is used for calling a first conversion service and converting the rtmp source into a target source, wherein the target source is a live source which is supported by the browser to play;
and the playing module is used for playing the streaming media live broadcast corresponding to the target source.
Optionally, the apparatus further comprises:
the first judging module is used for calling a streaming media live broadcast service interface according to the live broadcast identification of the streaming media to be played, and judging whether an rtsp source of the streaming media to be played can be acquired;
the starting module is used for starting a conversion process under the condition that the rtsp source can be obtained;
the acquisition module includes:
and the acquisition submodule is used for acquiring the rtmp source by utilizing the conversion process.
Optionally, a static dictionary is established in the streaming media live broadcast service, where the static dictionary is used to store an association relationship between an rtsp source address corresponding to an rtsp source and a target source address corresponding to a target source, and the obtaining sub-module includes:
the first query subunit is used for querying whether the static dictionary stores the association relationship between the rtsp source address and the target source address;
and the first obtaining subunit is configured to directly obtain the rtmp source when the static dictionary is queried to store the association relationship between the rtmp source address and the target source address.
Optionally, the obtaining sub-module may further include:
the rtsp source conversion subunit is used for calling a second conversion service to convert the rtsp source into the rtmp source and simultaneously return the target source address under the condition that the static dictionary is not inquired that the incidence relation between the rtsp source address and the target source address is stored;
and the second acquiring subunit is used for acquiring the converted rtmp source and the target source address.
The obtaining sub-module may further include:
the association relation establishing subunit is used for establishing an association relation between an rtsp source address corresponding to the rtsp source and a target source address corresponding to the target source;
the adding subunit is used for adding the incidence relation between the rtsp source address and the target source address into the static dictionary;
and the third acquiring subunit is used for inquiring the association relationship between the rtsp source address corresponding to the rtsp source and the target source address from the static dictionary when the rtsp source is acquired again, and directly acquiring the rtmp source.
Optionally, the apparatus further comprises:
the quitting and inquiring module is used for quitting the conversion process and inquiring whether the association relation between the rtsp source address and the target source address is stored in a static dictionary or not under the condition that the rtmp source cannot be obtained by utilizing the conversion process;
and the first deleting module is used for deleting the association relationship between the rtsp source address and the target source address from the static dictionary under the condition that the association relationship between the rtsp source address and the target source address is inquired and stored in the static dictionary.
Optionally, the apparatus further comprises:
a second determining module, configured to periodically determine whether an association relationship between the rtsp source address and the target source address stored in the static dictionary is available, where the association relationship between the rtsp source address and the target source address is unavailable when an rtsp source corresponding to the rtsp source address does not exist;
and the second deleting module is used for deleting the incidence relation between the rtsp source address and the target source address from the static dictionary under the condition that the incidence relation between the rtsp source address and the target source address stored in the static dictionary is unavailable.
Optionally, the apparatus further comprises:
and the returning module is used for returning an error prompt under the condition that the rtsp source for the stream media to be played is unavailable.
Optionally, the apparatus further comprises:
the second conversion module is used for converting the rtmp source into a websocket source when the browser is applied to a PC or an Android platform;
and the third conversion module is used for converting the rtmp source into an m3u8 source when the browser is applied to the iOS platform.
The embodiment of the invention also discloses a streaming media live broadcast device, which comprises:
one or more processors; and
one or more computer-readable media having instructions stored thereon, which when executed by the one or more processors, cause the apparatus to perform a method for live streaming media playback according to any of the embodiments of the present invention.
The embodiment of the invention also discloses a computer readable storage medium, and the stored computer program enables a processor to execute the streaming media live broadcast method in the embodiment of the invention.
The embodiment of the invention has the following advantages:
in this embodiment, when a user wants to directly play a streaming media to be played on a browser, a rtmp source of the streaming media to be played is acquired, a first conversion service is called, and the rtmp source is directly converted into a target source.
Drawings
Fig. 1 is a flowchart illustrating steps of a method for playing a live streaming media according to an embodiment of the present invention;
fig. 2 is a flow chart of a streaming media live broadcast service provided by an embodiment of the present invention;
fig. 3 is a flowchart of a method for playing a live streaming media according to an embodiment of the present invention;
fig. 4 is a block diagram of a structure of a live streaming media playing apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
At present, mainstream browsers in the market, including Google, Firefox, Safari and the like, all have their own live streaming media playing protocols, and for live streaming media source formats, that is, live streaming sources in rtsp format (rtsp source for short) or live streaming sources in rtmp format (rtmp source for short), the browsers cannot be directly opened, that is, the browsers do not support the browsers to directly play the rtsp source and rtmp source.
In the prior art, for these rtsp sources or rtmp sources, some related plug-ins are required for playing on a browser, and flash support is required, but the current mainstream browsers abandon flash and remove plug-ins, which undoubtedly brings difficulty to playing streaming media live through a web browser, and reduces convenience of playing streaming media live.
In addition, the formats of the live source supported by different systems are different, for example, the live source supported by the IOS system platform is in the m3u8 format, and the PC or Android platform can play the live source through the websocket format.
Based on the defects of the related technologies, one of the core concepts of the embodiments of the present invention is provided, and after an rtsp source or an rtmp source is obtained, the rtsp source or the rtmp source is converted, so that terminals of different systems can play a live stream of a streaming media in a format corresponding to a live source of a terminal of each system.
Referring to fig. 1, fig. 1 is a flowchart illustrating steps of a live streaming media playing method according to an embodiment of the present invention, where the method is applied to a browser, and the method specifically includes the following steps:
and step S11, acquiring the rtmp source of the stream media to be played.
And step S12, calling a first conversion service, and converting the rtmp source into a target source, wherein the target source is a live source supported by the browser for playing.
And step S13, playing the streaming media live broadcast corresponding to the target source.
In this embodiment, the browser may be various browsers on various devices (pc, Android, ios), such as Chrome, Safari, Firefox, a built-in browser (WeChat, QQ), and the like.
The to-be-played live streaming media refers to live streaming media which a user wants to play directly on a browser. Such as a live broadcast of a live platform.
The target source refers to a live source of the streaming media which is directly played by the browser. For example, the live source supported by the IOS system platform is a live source in m3u8 format, and therefore, a browser applied under the IOS system platform needs to acquire the live source in m3u8 format, that is, the rtmp source address is converted into an m3u8 source through a first conversion service; PC and Android equipment can use flv.js with a bilibili open source to play the websocket source, so that a browser under a PC or an Android platform needs to acquire a websocket-format live source, that is, the rtmp source is converted into the websocket source through a first conversion service.
By adopting the method provided by the embodiment of the invention, the streaming media live source can be directly played on the browser of the IOS system platform, and also can be directly played on the browser of a PC or Android platform, so that the method is convenient and quick.
In this embodiment, the rtsp source corresponds to the rtsp source address, the rtmp source corresponds to the rtmp source address, the target source corresponds to the target source address, and the corresponding rtsp source, rtmp source or target source can be found according to the rtsp source address, rtmp source address and target source address. The rtmp source of the streaming media to be played live broadcast can be obtained, then the first conversion service is called to convert the rtmp source into the target source, and then the browser can play the streaming media to be played live broadcast for the user to watch.
In this embodiment, the rtmp source has a rtmp source address, and the first conversion service may acquire the rtmp source from the rtmp source address and convert the rtmp source into the target source.
In this embodiment, the first conversion service may be a Node-Media-Server service, and the Node-Media-Server service is a set of script services written by Node js and capable of converting rtmp live broadcast sources into target sources such as m3u8 and websocket.
In the embodiment, when a user wants to directly play the streaming media to be played on the browser, the rtmp source of the streaming media to be played is obtained, the first conversion service is called, and the rtmp source is directly converted into the target source.
In addition, considering that in a normal case, a live broadcast source of streaming media includes an rtmp source and an rtmp source, and therefore, it is not necessarily the rtmp source that is obtained, and there may also be an rtmp source, referring to fig. 2, fig. 2 is a flow chart of streaming media live broadcast service provided in this embodiment of the present application, in this embodiment, before obtaining the rtmp source of the streaming media to be played live broadcast, the following steps may be further included:
step SA1, according to the live broadcast identifier of the to-be-played streaming media, calling an interface of a streaming media live broadcast service, and determining whether an rtsp source of the to-be-played streaming media live broadcast can be acquired.
Step SA2, if the rtsp source can be obtained, starts the conversion process.
Step SA3, the rtmp source is obtained by the conversion process.
In this embodiment, the live broadcast identifier is an identifier for searching live broadcasts of streaming media to be played when a user performs live broadcast access with a browser client, where the live broadcast identifier may be a room ID or a live broadcast number, and each live broadcast corresponds to a specific live broadcast identifier.
The streaming media live broadcast service refers to service for obtaining a target source address according to a live broadcast identifier of a request, and the target source address can be accessed by a browser so as to obtain a target source.
When the live broadcast access is carried out through a browser client, an interface of the streaming media live broadcast service is requested, a live broadcast identification is introduced, the streaming media live broadcast service interface is called according to the live broadcast identification, at this time, whether an rtsp source of the streaming media to be played and live broadcast corresponding to the live broadcast identification can be obtained or not needs to be judged, specifically, if the rtsp source can be returned, the live broadcast is indicated, a live broadcast stream exists, the rtsp source of the streaming media to be played and live broadcast can be obtained, and an rtsp source address is correspondingly obtained.
Because the rtsp source cannot be directly converted into the live source supported by the browser, and the rtmp source can be converted into the source supported by the browser, a user wants to directly play the streaming media live source on the browser, after acquiring the rtsp source, the user can start a conversion process, convert the rtsp source into the rtmp source and correspondingly obtain an rtmp source address, and after acquiring the rtmp source, the rtmp source is used for converting into the live source in the format supported by the browser.
In this embodiment, the conversion process may be an ffmpeg process, and the conversion process may be included in the streaming media live broadcast service or may be independent of the streaming media live broadcast service.
The ffmpeg Process is an open source computer program used for recording, converting digital audio and video and converting the digital audio and video into streams, and can be executed by a called Process.
In practice, a user may have a need to play multiple live streaming media in the browser, and thus, multiple conversion processes may exist simultaneously. At this time, Task can be used to enable the multithread calling Process to execute the ffmpeg program, and perform the rtsp-to-rtmp source conversion Process.
By adopting the method of the embodiment, not only the rtmp source can be converted, but also the rtmp source can be converted, so that the browser can directly play the streaming media of the rtmp source and the rtmp source for live broadcasting.
Referring to fig. 3, fig. 3 is a flowchart of a live streaming media playing method provided in an embodiment of the present invention, because a live streaming media to be played corresponding to an incoming live broadcast identifier may not be live broadcast, and there is no live broadcast stream, at this time, an rtsp source of the live streaming media to be played cannot be acquired, that is, an rtsp source returned after a live streaming media service interface is called is empty, a conversion process cannot be entered, and an error prompt false is returned.
For example, a user wants to view a live program of a live platform, the live program is a live broadcast of the streaming media to be played, a room ID (live broadcast identifier) of the live program is 101, the room ID101 is introduced into a search window of a browser, if the live program is not live broadcast, an error prompt is returned to the browser and displayed on a browser interface for the user to view, and the user can know the live broadcast state of the streaming media to be played conveniently.
With reference to fig. 3, in an embodiment of the present invention, a static dictionary is established in a streaming media live service, and the static dictionary is configured to store an association relationship between an rtsp source address corresponding to the rtsp source and a target source address corresponding to the target source, where in this embodiment, the step SA3 of obtaining the rtmp source by using the conversion process may specifically include the following steps:
step SB1, it is queried whether the static dictionary stores the association relationship between the rtsp source address and the target source address.
Step SB2, directly acquiring the rtmp source when the static dictionary is queried to store the association relationship between the rtmp source address and the target source address.
In this embodiment, since the association relationship between the rtsp source address and the target source address (the websocket address and the m3u8 address) stored in the static dictionary can be queried, it is described that an operation of converting the rtsp source corresponding to the requested live broadcast identifier into the rtmp source through the ffmpeg service has been performed before, and therefore when the association relationship between the rtsp source address and the target source address is subsequently queried to be stored in the static dictionary, the corresponding rtmp source can be directly obtained.
The rtsp source corresponding to the requested live broadcast identification is converted into the rtmp source through the ffmpeg service, an rtsp source address corresponding to the rtsp source, an rtmp source address corresponding to the rtmp source and a target source address corresponding to the target source can be returned, wherein the returned target source addresses comprise a websocket address and an m3u8 address, the corresponding target source address is selected and sent for the browser to access according to a platform system of the browser by utilizing the Node-Media-Server service, the browser accesses the target source address to obtain the target source, and therefore the function of playing the live broadcast of the streaming Media to be played is achieved.
Of course, the returned destination source address may only include any one of the websocket address and the m3u8 address according to the platform system on which the browser operates, which is not limited herein.
In this embodiment, the static dictionary is equivalent to a book and is used to store a corresponding relationship or association relationship between an rtsp source address and a target source address corresponding to a live broadcast identifier of a request, and since an rtmp address has confidentiality and cannot be exposed, an association relationship between an rtsp source address and a target source address is preferably established in the static dictionary.
The static dictionary stores key-value pairs, the number of the key-value pairs can be multiple, an rtsp source address is the key in the dictionary, the value stores a class, and the class can comprise two fields of a websocket address and an m3u8 address. For example, taking a PC or an Android platform as an example, the requested live broadcast identifier is 1208, the streaming media live broadcast service acquires a rtsp source according to 1208, and correspondingly acquires a rtsp source address, where the rtsp source address is a key in the static dictionary, and according to the rtsp source address, a websocket address (an address accessed by a PC or an Android platform browser) and an m3u8 address (an address accessed by an iOS platform browser) can be queried in a value, for example, the websocket address is ws:// 127.0.1/1208. flv, and the m3u8 address is http:// 127.0.1: 8000/1208/index.m3u8.
In this embodiment, after acquiring the rtsp source address and starting the conversion process, first, it may be queried whether a static dictionary has an rtsp source address corresponding to a key as a requested live broadcast identifier, and a value is a key-value pair of a target source address associated with the rtsp source address corresponding to the requested live broadcast identifier, if the key-value pair exists, it is described that the static dictionary stores an association relationship between the rtsp source address and the target source address, and a request for converting the rtsp source corresponding to the live broadcast identifier into an rtmp has been made before, at this time, the conversion process may directly acquire the rtmp source address associated with the rtsp source address by using the association relationship, and further access the rtmp source address to acquire the rtmp source address, and may directly acquire the rtmp source according to the rtmp source address and acquire the corresponding rtsp source address and the target source address by using the association relationship between the rtsp source address and the target source address stored in the static dictionary, the conversion time of the conversion process is saved.
With reference to fig. 3, in an embodiment of the present invention, if the static dictionary does not have the association relationship between the rtsp source address and the target source address after querying whether the static dictionary has the association relationship between the rtsp source address and the target source address, for example, the streaming media live broadcast service is a service for executing the rtsp source corresponding to the request live broadcast identifier for the first time, the static dictionary does not have the rtsp source and the rtsp source address corresponding to the requested live broadcast identifier stored in advance, and the key value pair of the rtsp source address corresponding to the live broadcast identifier and the target source address associated with the rtsp source address is not stored. In this embodiment, after querying whether the static dictionary stores the association relationship between the rtsp source address and the target source address, the method may further include the following steps:
step SC1, when the static dictionary is not queried to store the association relationship between the rtsp source address and the target source address, call a second conversion service to convert the rtsp source into the rtmp source, and return the target source address.
And step SC2, acquiring the rtmp source and the target source address after conversion.
In this embodiment, under the condition that the static dictionary is not queried to store the association relationship between the rtsp source address and the target source address, the rtmp source cannot be directly obtained, at this time, a second conversion service may be called to convert the rtsp source into the rtmp source, and the target source address is returned at the same time, so that the converted rtmp source can be obtained after conversion.
In this embodiment, the second conversion service may be a service of a process that converts an rtsp source into an rtmp source in an ffmpeg process.
Referring to fig. 2 and fig. 3, in this embodiment, in order to save the computation cost of the system, after the rtmp source and the destination source address after the conversion are obtained in step SC2, the following steps may be further included:
and step SD1, establishing an incidence relation between the rtsp source address corresponding to the rtsp source and the target source address corresponding to the target source.
And step SD2, adding the incidence relation between the rtsp source address and the target source address into the static dictionary.
And step SD3, when the rtsp source is obtained again, inquiring the association relation between the rtsp source address corresponding to the rtsp source and the target source address from the static dictionary, and directly obtaining the rtmp source.
In this embodiment, after the second service calculation, an rtmp source corresponding to an rtsp source may be obtained, and at the same time, an rtsp source address corresponding to the rtsp source and a target source address corresponding to the target source may be obtained, so that an association relationship between the rtsp source address and the target source address may be established, and the established association relationship between the rtsp source address and the target source address is added to the static dictionary, that is, a key-value pair is added to the static dictionary, and since an operation of converting the rtmp source corresponding to the requested live broadcast identifier into the rtmp source through the ffmpeg service has been performed, after the rtsp source is obtained again according to the live broadcast identifier, it may be queried that when the association relationship between the rtsp source address and the target source address is stored in the static dictionary, the corresponding rtmp source may be directly obtained, and the target source address may be directly obtained without calling the second conversion service for conversion, the second conversion service can be prevented from being called for conversion after the rtsp source is acquired every time, the calculation cost of the second conversion service is saved, and the conversion time can be saved.
In an embodiment of the present invention, it is considered that, during the running process of the transition process, the running state of the transition process may be monitored, for example, after entering the transition process, in a normal case, the rtsp source always exists, that is, the live source always exists, and at this time, the transition process may be monitored as normal, that is, the rtmp source can be continuously obtained. However, when the live source is suddenly disconnected, so that an rtsp source does not exist, the conversion process can be monitored to be abnormal, that is, the rtmp source cannot be acquired. In this embodiment, after the conversion process is started, the following steps may be specifically included:
and step SE1, under the condition that the rtmp source cannot be obtained by the conversion process, exiting the conversion process, and inquiring whether the static dictionary stores the incidence relation between the rtmp source address and the target source address.
And step SE2, when the static dictionary is inquired that the association relationship between the rtsp source address and the target source address is stored, deleting the association relationship between the rtsp source address and the target source address from the static dictionary.
Still taking the example that the conversion Process is an ffmpeg Process as an example for explanation, the Process calls ffmpeg to monitor the running state of the ffmpeg Process, and also monitor whether the rtmp source can be acquired through the ffmpeg Process, and also monitor the exit of the ffmpeg Process. Therefore, under the condition that the rtmp source cannot be obtained through the ffmpeg process, the ffmpeg process can be exited, whether the association relationship between the rtmp source address and the target source address is stored in the static dictionary can be inquired, if the association relationship between the rtmp source address and the target source address is stored in the static dictionary is inquired, the key value pair in the static dictionary is directly deleted, and if the association relationship between the rtmp source address and the target source address is not stored in the static dictionary, no operation is required, the key value pair in the static dictionary can be timely processed by adopting the method of the embodiment, the accuracy of the key value pair in the static dictionary is ensured, and the conversion efficiency of the subsequent conversion process is improved.
In an embodiment of the present invention, considering that a static dictionary is size-limited, when a data is read from the static dictionary, the smaller the data amount in the static dictionary is, the faster the reading speed is, so that the key-value pair expressing the association relationship between an rtsp source address and a target source address stored in the static dictionary is managed, and the static dictionary, for example, a user starts playing a plurality of live broadcast sources at the same time, when the user does not want to play one of the live broadcast sources, the conversion process of one of the live broadcast sources is normally exited, and at this time, the key-value pair expressing the association relationship between the rtsp source address and the target source address in the static dictionary is not deleted, so that the key-value pair is retained in the static dictionary, but after a period of time, the live broadcast source is disconnected, that is, the rtsp source does not exist, and it has no meaning that the static dictionary stores the association relationship between the rtsp source address and the rtmp source address, the method may further comprise the steps of:
step SF1, periodically judging whether the incidence relation between the rtsp source address and the target source address stored in the static dictionary is available, wherein when the rtsp source corresponding to the rtsp source address does not exist, the incidence relation between the rtsp source address and the target source address is unavailable
Step SF2, when the association relationship between the rtsp source address and the target source address stored in the static dictionary is unavailable, deleting the association relationship between the rtsp source address and the target source address from the static dictionary.
In this embodiment, it is periodically determined whether the association relationship between the rtsp source address and the rtmp source address in the static dictionary is available, specifically, a polling task is added to poll whether a key-value in the dictionary is available, that is, whether an rtsp source corresponding to the rtsp source address exists is checked, and if not, the key-value pair is deleted.
In this embodiment, the polling period may be set to 5 minutes or 10 minutes, and is not limited specifically here.
In the embodiment, whether the incidence relation between the rtsp source address and the rtmp source address in the static dictionary is available or not is periodically judged, and the key value pair is deleted when the incidence relation is unavailable, so that the unavailable key value pair in the static dictionary can be deleted in time, the key value pair in the static dictionary is ensured to be in a limited range, and the query and reading speed of the static dictionary is improved.
Based on the same technical concept, please refer to fig. 4, fig. 4 shows a live streaming media playing apparatus 40 according to an embodiment of the present invention, where the apparatus includes:
an obtaining module 41, configured to obtain an rtmp source of a live streaming media to be played;
a first conversion module 42, configured to invoke a first conversion service, and convert the rtmp source into a target source, where the target source is a live source that the browser supports playing;
and the playing module 43 is configured to play the streaming media live broadcast corresponding to the target source.
Optionally, the apparatus further comprises:
the first judging module is used for calling a streaming media live broadcast service interface according to the live broadcast identification of the streaming media to be played, and judging whether an rtsp source of the streaming media to be played can be acquired;
the starting module is used for starting a conversion process under the condition that the rtsp source can be obtained;
the acquisition module includes:
and the acquisition submodule is used for acquiring the rtmp source by utilizing the conversion process.
Optionally, a static dictionary is established in the streaming media live service, and the static dictionary is used for storing an association relationship between an rtsp source address corresponding to an rtsp source and a target source address corresponding to a target source, and the obtaining sub-module includes:
the first query subunit is used for querying whether the static dictionary stores the association relationship between the rtsp source address and the target source address;
and the first obtaining subunit is configured to directly obtain the rtmp source when the static dictionary is queried to store the association relationship between the rtmp source address and the target source address.
Optionally, the obtaining sub-module may further include:
the rtsp source conversion subunit is used for calling a second conversion service to convert the rtsp source into the rtmp source and return a target source address under the condition that the static dictionary is not inquired that the incidence relation between the rtsp source address and the target source address is stored;
and the second acquisition subunit is used for acquiring the rtmp source and the target source address after conversion.
The obtaining sub-module may further include:
the association relationship establishing subunit is used for establishing an association relationship between the rtsp source address corresponding to the rtsp source and the target source address corresponding to the target source;
the adding subunit is used for adding the incidence relation between the rtsp source address and the target source address into the static dictionary;
and the third acquiring subunit, when acquiring the rtsp source again, inquires the association relationship between the rtsp source address corresponding to the rtsp source and the target source address from the static dictionary, and directly acquires the rtmp source.
Optionally, the apparatus further comprises:
the quitting and inquiring module is used for quitting the conversion process and inquiring whether the association relation between the rtsp source address and the target source address is stored in a static dictionary or not under the condition that the rtmp source cannot be obtained by utilizing the conversion process;
and the first deleting module is used for deleting the association relationship between the rtsp source address and the target source address from the static dictionary under the condition that the association relationship between the rtsp source address and the target source address is inquired and stored in the static dictionary.
Optionally, the apparatus further comprises:
a second determining module, configured to periodically determine whether an association relationship between the rtsp source address and the target source address stored in the static dictionary is available, where the association relationship between the rtsp source address and the target source address is unavailable when an rtsp source corresponding to the rtsp source address does not exist;
and the second deleting module is used for deleting the incidence relation between the rtsp source address and the target source address from the static dictionary under the condition that the incidence relation between the rtsp source address and the target source address stored in the static dictionary is unavailable.
Optionally, the apparatus further comprises:
and the returning module is used for returning an error prompt under the condition that the rtsp source for the stream media to be played is unavailable.
Optionally, the apparatus further comprises:
the second conversion module is used for converting the rtmp source into a websocket source when the browser is applied to a PC or an Android platform;
and the third conversion module is used for converting the rtmp source into an m3u8 source when the browser is applied to the iOS platform.
An embodiment of the present invention further provides a streaming media live broadcast device, including:
one or more processors; and
one or more computer-readable media having instructions stored thereon, which when executed by the one or more processors, cause the apparatus to perform a method for live streaming media playing according to any one of the embodiments of the present invention.
The embodiment of the invention also provides a computer-readable storage medium, and a stored computer program enables a processor to execute the live streaming media playing method according to the embodiment of the invention.
As for the embodiment of the streaming media live broadcast device, since it is basically similar to the embodiment of the streaming media live broadcast method, the description is relatively simple, and relevant points can be referred to only by referring to part of the description of the embodiment of the streaming media live broadcast method.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one of skill in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention 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 so forth) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams 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 terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, 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 terminal 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 terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or terminal equipment comprising the element.
The present invention provides a live streaming media playing method, a live streaming media playing device and a computer readable storage medium, which have been described in detail above, and specific examples are applied herein to explain the principles and embodiments of the present invention, and the descriptions of the above embodiments are only used to help understand the method and the core ideas of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method for playing live streaming media is applied to a browser, and comprises the following steps:
acquiring a rtmp source for live broadcasting of streaming media to be played;
calling a first conversion service, and converting the rtmp source into a target source, wherein the target source is a live source which is supported by the browser to play;
playing the streaming media live broadcast corresponding to the target source;
before the obtaining of the rtmp source of the streaming media to be played, the method further includes:
calling a streaming media live broadcast service interface according to the live broadcast identification of the streaming media to be played, and judging whether a rtsp source for the streaming media to be played can be obtained or not;
starting a conversion process under the condition that the rtsp source can be obtained;
the acquiring the rtmp source of the streaming media to be played comprises:
acquiring the rtmp source by utilizing the conversion process;
a static dictionary is established in the streaming media live broadcast service, the static dictionary is used for storing an incidence relation between an rtsp source address corresponding to an rtsp source and a target source address corresponding to a target source, and the obtaining of the rtmp source by using the conversion process includes:
inquiring whether the static dictionary stores the incidence relation between the rtsp source address and the target source address or not;
and under the condition that the incidence relation between the rtsp source address and the target source address is stored in the static dictionary, directly acquiring the rtmp source.
2. The method according to claim 1, wherein after the query static dictionary stores the association relationship between the rtsp source address and the target source address, the method further comprises:
under the condition that the incidence relation between the rtsp source address and the target source address is not stored in the static dictionary, calling a second conversion service to convert the rtsp source into the rtmp source and simultaneously returning the target source address;
and acquiring the rtmp source and the target source address after conversion.
3. The method of claim 2, wherein after the obtaining the converted rtmp source and destination source address, the method further comprises:
establishing an incidence relation between an rtsp source address corresponding to the rtsp source and a target source address corresponding to the target source;
adding the incidence relation between the rtsp source address and the target source address into the static dictionary;
and when the rtsp source is obtained again, inquiring the association relation between the rtsp source address corresponding to the rtsp source and the target source address from the static dictionary, and directly obtaining the rtmp source.
4. The method of claim 1, wherein after the initiating a transition process, the method further comprises:
under the condition that the rtmp source cannot be obtained by utilizing the conversion process, quitting the conversion process, and inquiring whether a static dictionary stores the incidence relation between the rtmp source address and the target source address;
and under the condition that the static dictionary is inquired to store the incidence relation between the rtsp source address and the target source address, deleting the incidence relation between the rtsp source address and the target source address from the static dictionary.
5. The method of claim 1, further comprising:
periodically judging whether the incidence relation between the rtsp source address and the target source address stored in the static dictionary is available, wherein the incidence relation between the rtsp source address and the target source address is unavailable when the rtsp source corresponding to the rtsp source address does not exist;
and under the condition that the incidence relation between the rtsp source address and the target source address stored in the static dictionary is unavailable, deleting the incidence relation between the rtsp source address and the target source address from the static dictionary.
6. The method according to claim 1, wherein after determining whether an rtsp source for live streaming media to be played can be acquired, the method further comprises:
and returning an error prompt under the condition that an rtsp source for live broadcasting of the streaming media to be played cannot be obtained.
7. The method of claim 1, wherein said converting the rtmp source to a target source comprises:
when the browser is applied to a PC or an Android platform, the rtmp source is converted into a websocket source;
when the browser is applied to the iOS platform, the rtmp source is converted into an m3u8 source.
8. A live streaming media playing device is applied to a browser, and the device comprises:
the acquisition module is used for acquiring a rtmp source for live broadcasting of streaming media to be played;
the first conversion module is used for calling a first conversion service and converting the rtmp source into a target source, wherein the target source is a live source which is supported by the browser to play;
the playing module is used for playing the streaming media live broadcast corresponding to the target source;
the device further comprises:
the first judging module is used for calling a streaming media live broadcast service interface according to the live broadcast identification of the streaming media to be played, and judging whether an rtsp source for the live broadcast of the streaming media to be played can be acquired;
the starting module is used for starting a conversion process under the condition that the rtsp source can be obtained;
the acquisition module includes:
the obtaining submodule is used for obtaining the rtmp source by utilizing the conversion process;
a static dictionary is established in the streaming media live broadcast service, the static dictionary is used for storing an incidence relation between an rtsp source address corresponding to an rtsp source and a target source address corresponding to a target source, and the obtaining of the rtmp source by using the conversion process includes:
the first query subunit queries whether the static dictionary stores the incidence relation between the rtsp source address and the target source address;
and the first acquisition subunit directly acquires the rtmp source under the condition that the association relationship between the rtmp source address and the target source address is stored in the static dictionary.
9. A live streaming media playing device is characterized by comprising:
one or more processors; and
one or more computer-readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform a method of live streaming media playback as recited in any of claims 1-7.
10. A computer-readable storage medium storing a computer program for causing a processor to execute the live streaming media playing method according to any one of claims 1 to 7.
CN201911039660.XA 2019-10-29 2019-10-29 Streaming media live broadcast method and device and computer readable storage medium Active CN110891051B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911039660.XA CN110891051B (en) 2019-10-29 2019-10-29 Streaming media live broadcast method and device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911039660.XA CN110891051B (en) 2019-10-29 2019-10-29 Streaming media live broadcast method and device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN110891051A CN110891051A (en) 2020-03-17
CN110891051B true CN110891051B (en) 2022-08-30

Family

ID=69746572

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911039660.XA Active CN110891051B (en) 2019-10-29 2019-10-29 Streaming media live broadcast method and device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN110891051B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111901634B (en) * 2020-07-31 2022-07-08 北京嘀嘀无限科技发展有限公司 Stream media on-demand method, device and computer readable storage medium
CN112995698A (en) * 2021-05-19 2021-06-18 浙江华创视讯科技有限公司 Video playing method, client, service platform and intelligent conference system
CN113794932A (en) * 2021-09-15 2021-12-14 云茂互联智能科技(厦门)有限公司 Method and device for playing video stream at webpage end, electronic equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104639905B (en) * 2015-02-03 2016-07-06 广西智询信息科技有限公司 A kind of wireless video monitoring method thereof suitable in iOS system live broadcast of mobile terminal
WO2018027237A1 (en) * 2016-08-05 2018-02-08 Sportscastr.Live Llc Systems, apparatus, and methods for scalable low-latency viewing of broadcast digital content streams of live events
CN108243173B (en) * 2016-12-27 2019-08-06 视联动力信息技术股份有限公司 A kind of RTMP video pushing method and device based on view networking
CN109286603A (en) * 2017-07-20 2019-01-29 深圳市道通智能航空技术有限公司 A kind of method and apparatus for realizing network direct broadcasting
CN107682710A (en) * 2017-10-11 2018-02-09 湖南纽曼车联网科技有限公司 A kind of net cast method and live broadcast system
CN107995187A (en) * 2017-11-30 2018-05-04 上海哔哩哔哩科技有限公司 Video main broadcaster, live broadcasting method, terminal and system based on HTML5 browsers

Also Published As

Publication number Publication date
CN110891051A (en) 2020-03-17

Similar Documents

Publication Publication Date Title
CN110891051B (en) Streaming media live broadcast method and device and computer readable storage medium
JP5666477B2 (en) Server-side support for seamless rewind and playback of video streaming
CN105975470B (en) Historical record processing method and device
US20160294903A1 (en) Method and device for pushing resources to mobile communication terminal by smart television
EP3754998B1 (en) Streaming media quality monitoring method and system
CN111385316A (en) Resource refreshing method, access method and device
CN105354195B (en) Information searching method and device
CN112218166A (en) Play starting method and related device for memory play of on-demand video
CN110740386A (en) Live broadcast switching method and device and storage medium
CN111897978A (en) Live broadcast state monitoring method and device, electronic equipment and storage medium
CN110113298B (en) Data transmission method, device, signaling server and computer readable medium
CN107948234B (en) Data processing method and device
CN109446445B (en) Resource acquisition method and device
US11184687B2 (en) Wearable device, information processing method, apparatus and system
CN108966041B (en) Audio and video playing point burying method, device, equipment and computer readable storage medium
CN114640657A (en) Multi-registration center fusion method and device
CN109587517B (en) Multimedia file playing method and device, server and storage medium
CN111193942B (en) Streaming media playback method and device
CN110868643B (en) Method and device for determining video downloading progress
JP2005526305A (en) Method and apparatus for obtaining internet content for a wireless device
CN109729419B (en) Push video preloading method and device, electronic equipment and storage medium
CN115019231A (en) Video frame identification method and device, electronic equipment and storage medium
CN113220654A (en) Content sharing method, device and system and storage medium
CN108564971B (en) Audio playing method and device
CN112933611A (en) Cloud game progress sharing method and device and electronic equipment

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
CP03 Change of name, title or address

Address after: 33rd Floor, No.1 Huasheng Road, Yuzhong District, Chongqing 400013

Patentee after: VISIONVERA INFORMATION TECHNOLOGY Co.,Ltd.

Country or region after: China

Address before: 100000 Beijing Dongcheng District Qinglong Hutong 1 Song Hua Building A1103-1113

Patentee before: VISIONVERA INFORMATION TECHNOLOGY Co.,Ltd.

Country or region before: China