Disclosure of Invention
In view of the above, the present invention provides an offset correction method and apparatus for a current playlist of a smart television, so as to solve the problem that a live video stream in the smart television cannot be synchronized with a program source server in the prior art.
Specifically, the invention is realized by the following technical scheme:
in one aspect, the present invention provides an offset correction method for a current playlist of a smart television, where the method includes:
acquiring actual playing time corresponding to a slice file in a current playing list;
traversing the slice files in the current play list and judging whether the current play list has invalid slice files according to the actual play time corresponding to the slice files;
and if the invalid slice file exists, deleting the invalid slice file from the current play list, and updating the tag value of the current play list.
Optionally, the obtaining of the actual playing time corresponding to the slice file in the current playlist specifically includes:
and acquiring the synchronous time difference between the intelligent television and the program source server, and configuring the sum of the current time of the intelligent television and the synchronous time difference as the actual playing time corresponding to the slice file in the current playing list.
Optionally, the obtaining of the synchronization time difference between the smart television and the program source server specifically includes:
sending a request message to a program source server, and recording the starting time of sending the request message by the intelligent television;
receiving a response message returned by the program source server aiming at the request message, and recording the end time when the smart television receives the response message;
and calculating the synchronous time difference between the intelligent television and the program source server according to the starting time and the ending time.
Optionally, the traversing the slice file in the current playlist and determining whether a failed slice file exists in the current playlist according to the actual playing time corresponding to the slice file specifically includes:
traversing a current play list sent by a program source server, wherein the current play list comprises a slice file and a timestamp of the slice file, and the timestamp is effective play time set for the slice file by the program source server;
and if the time stamp of the slice file is earlier than the actual playing time, the slice file is a failed slice file.
Optionally, the updating the tag value of the current playlist specifically includes:
and updating the EXT-X-DISCONTINUITY label of the current playlist, and performing re-initialization on the parameter value.
In another aspect, based on the same concept, the present invention further provides an offset correction apparatus for a current playlist of a smart tv, the apparatus including:
the time acquisition unit is used for acquiring the actual playing time corresponding to the slice file in the current playing list;
the failure judgment unit is used for traversing the slice files in the current play list and judging whether the failed slice files exist in the current play list according to the actual play time corresponding to the slice files;
and the file deleting unit is used for deleting the invalid slice file from the current playlist and updating the label value of the current playlist if the invalid slice file exists.
Optionally, the time obtaining unit includes:
the first subunit is used for acquiring the synchronous time difference between the intelligent television and the program source server;
and the second subunit is used for configuring the sum of the current time of the smart television and the synchronization time difference as the actual playing time corresponding to the slice file in the current playlist.
Optionally, the first subunit is specifically configured to:
sending a request message to a program source server, and recording the starting time of sending the request message by the intelligent television; receiving a response message returned by the program source server aiming at the request message, and recording the end time when the smart television receives the response message; and calculating the synchronous time difference between the intelligent television and the program source server according to the starting time and the ending time.
Optionally, the failure determining unit is specifically configured to:
traversing a current play list sent by a program source server, wherein the current play list comprises a slice file and a timestamp of the slice file, and the timestamp is effective play time set for the slice file by the program source server; and if the time stamp of the slice file is earlier than the actual playing time, the slice file is a failed slice file.
Optionally, the file deleting unit is specifically configured to:
and updating the EXT-X-DISCONTINUITY label of the current playlist, and performing re-initialization on the parameter value.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
the method and the device can acquire the actual playing time corresponding to the slice file in the current playing list, traverse the slice file in the current playing list and judge whether the current playing list has a failed slice file according to the actual playing time corresponding to the slice file; and if the invalid slice file exists, deleting the invalid slice file from the current playlist, and updating the tag value of the current playlist. The current play list comprises the time stamp set by the program source server for the slice file, so that the slice file in the current play list and the slice file of the program source server can be played synchronously according to the time stamp, the problem of content deviation caused by transmission time delay and play time delay is solved, the play progress of different intelligent televisions is corrected, and the user experience of the intelligent television user on the live network video stream with higher real-time requirement is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Before explaining the embodiments of the present invention in detail, an application scenario of the embodiments of the present invention will be described. As shown in fig. 1, the video playing scene main device to which the offset correction method for the current playlist of the smart television is applied includes: program source server and intelligent TV, pass through Http network connection between the two, wherein:
the program source server is used for continuously providing a real-time video stream to the smart television, wherein the real-time video stream contains a playlist describing each slice file (for example, M3U8 TS slice files);
the intelligent television is used for acquiring a play list in the program source server and completing corresponding operations such as audio and video data initialization, coding and the like according to a slice file address provided by the play list so as to realize video playing. In an optional embodiment, the smart television comprises a channel proxy service module and a video playing module, wherein the channel proxy service module is configured to provide a playlist in a program source server to the video playing module of the smart television; the video playing module is used for carrying out corresponding operations such as audio and video data initialization, coding and the like according to the slice file address obtained from the play list, so as to realize video playing.
In order to solve the problems in the prior art, the invention provides an offset correction method and device for a current playlist of a smart television, which can acquire the actual playing time corresponding to a slice file in the current playlist, traverse the slice file in the current playlist according to the actual playing time corresponding to the slice file, and judge whether a failed slice file exists in the current playlist; and if the invalid slice file exists, deleting the invalid slice file from the current playlist, and updating the tag value of the current playlist. The current play list comprises the time stamp set by the program source server for the slice file, so that the slice file in the current play list and the slice file of the program source server can be played synchronously according to the time stamp, the problem of content deviation caused by transmission time delay and play time delay is solved, the play progress of different intelligent televisions is corrected, and the user experience of the intelligent television user on the live network video stream with higher real-time requirement is improved.
Referring to fig. 2, a flowchart of a method for offset correction of a current playlist of a smart tv according to an exemplary embodiment of the present invention is shown, where the method includes:
step 201, acquiring actual playing time corresponding to a slice file in a current playlist;
in this embodiment, the smart television may request a playlist from the program source server through the Http network, so as to obtain a current playlist sent by the program source server, where the playlist may include a tag value and a slice file, each slice file includes a timestamp corresponding to the slice file, and the timestamp is effective playing time set for the slice file by the program source server.
As an embodiment, the content of the current playlist of the present invention specifically includes:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=747800,RESOLUTION=640x480,CODECS="avc1.640014,mp4a.40.2"
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:611075
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:00Z
20160607T084833-12-611075.ts
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:10Z
20160607T084833-12-611076.ts
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:20Z
20160607T084833-12-611077.ts
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:30Z
20160607T084833-12-611078.ts
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:40Z
20160607T084833-12-611079.ts
wherein, the first four rows represent coding modes; documents suffixed with ". ts" are slide documents such as "20160607T 084833-12-611075.ts," 20160607T084833-12-611076.ts, "and the like; each slice file is provided with the TIME stamp of the slice file, namely the character string at the beginning of EXT-X-PROGRAM-DATE-TIME, for example, the TIME stamp corresponding to 20160607T084833-12-611075.ts is 2016-08-17T06:38:00Z, and the TIME stamp corresponding to 20160607T084833-12-611076.ts is 2016-08-17T06:38: 10Z. Other matters in the above examples do not relate to the gist of the present invention, and are not described in detail herein.
In this embodiment, after the smart television acquires the current playlist, the actual playing time corresponding to the slice file in the current playlist may be acquired, where the actual playing time refers to the actual time when the smart television plays the slice file. In this embodiment, the current time of the smart television may be used as the actual playing time of the slice file, and in consideration of the network transmission delay between the smart television and the program source server, the time of the network transmission delay is referred to as the synchronization time difference between the smart television and the program source server, so that the sum of the current time of the smart television and the synchronization time difference may also be used as the actual playing time of the slice file. For example, the current time of the smart television is 10:10:20, and the synchronization time difference is 5 seconds, then the actual playing time is 10:10: 25.
As an embodiment, a method for acquiring a synchronization time difference between a local computer and a program source server by an intelligent television specifically includes that the intelligent television sends a request message to the program source server, and records a start time of sending the request message by the intelligent television; then receiving a response message returned by the program source server aiming at the request message, and recording the end time when the smart television receives the response message; and calculating the synchronous time difference between the intelligent television and the program source server according to the starting time and the ending time.
For example, if the local time t1 when the smart television sends the http request message to the program source server is 10:10:10, t1 is the start time; when the smart television receives the response message replied by the program source server, the local time t2 is 10:10:15, and then t2 is the end time; the synchronization time difference is the difference between the start time and the end time, i.e. t2-t1 is 5 seconds, then the synchronization time difference between the smart television and the program source server is 5 seconds. In practical applications, the time of the network transmission delay between the smart television and the program source server may be changed due to a change in the network state, and in order to obtain a more accurate synchronization time difference, the smart television may further average and calculate a final synchronization time difference according to the synchronization time differences calculated several times, or may also average and calculate a final synchronization time difference by weighting. The calculation method of the synchronization time difference is only an exemplary illustration, and is not limited in practical application.
Step 202, traversing the slice files in the current playlist and judging whether the current playlist has failed slice files according to the actual playing time corresponding to the slice files;
after the time playing time corresponding to the slice file is obtained, the smart television may traverse the slice file in the current play list according to the time playing time, as an embodiment, the current play list may include the slice file and a timestamp of the slice file, where the timestamp is effective playing time set for the slice file by the program source server. The smart television can further compare the time stamp of the slice file with the actual playing time, and if the time stamp of the slice file is earlier than the actual playing time, the slice file is a failed slice file.
For example, the actual playing time of the smart television is 10:10: 25; if the time stamp of the slice file is 10:10:15, the slice file is considered to be invalid because the time stamp 10:10:15 of the slice file is earlier than the actual playing time 10:10: 25; if the time stamp of the slice file is 10:10:35, the slice file is considered valid because the time stamp of the slice file is 10:10:35 later than the actual playing time 10:10: 25.
Since the current playlist in the prior art only contains the slice files and does not have timestamps corresponding to the slice files, the smart television cannot determine the effective playing time of the slice files in the current playlist after acquiring the current playlist, and therefore the current playlist can only be played according to the local current time, which results in that whether the slice files are invalid or not cannot be determined. Each slice file in the current play list has a corresponding time stamp, which can represent the effective play time of the slice file, so that the invalid slice file can be screened out by comparing the actual play time with the time stamp, and the offset correction of the video stream is realized. In addition, as the time stamp is set for the slicing file by the program source server, and the time stamps of the same slicing file received by different intelligent televisions are the same, the invention can ensure that the synchronous playing of the video can be realized by comparing the same time stamp by different intelligent televisions.
Step 203, if there is a failed slice file, deleting the failed slice file from the current playlist, and updating the tag value of the current playlist.
After the current playlist is traversed to obtain the failed slice file, the failed slice file can be deleted from the current playlist. Since the playlist changes after deleting the expired slice file, the tag value of the current playlist can be updated. The method and the device can correct the playing of the live video stream by deleting the invalid slice file, thereby ensuring the synchronous playing of the live video streams of different players and the program source server.
As an embodiment, the smart television updates a tag value of a current playlist, which mainly refers to updating an EXT-X-DISCONTINUITY tag in the playlist, where the tag is used to indicate different encodings of a slice file of the current playlist and a slice file of a previous playlist, and if the slice file of the current playlist changes, parameter values of the tag, such as encoding parameters, file formats, and other parameters, need to be reinitialized.
As an embodiment, in order to better correct the current playlist, an update flag may be added to the playlist, and the attribute of the update flag includes updated and non-updated, for example, 0 may be used to indicate updated and 1 may be used to indicate non-updated. After obtaining the current playlist, the channel proxy service layer may further determine whether the tag value of the current playlist needs to be updated according to the update flag of the previous playlist; for example, if the attribute value of the update flag is 0, the update is not necessary, and if the attribute value of the update flag is 1, the update is necessary. If the current playlist needs to be updated, the channel proxy service layer may update the tag value of the current playlist, and the update method of the tag value may refer to the tag value update method in the previous embodiment. After the tag value is updated, the attribute of the update flag may be set to be updated in the current playlist.
As an embodiment, a specific method for updating a tag is as follows:
(1) playlist before tag update:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=747800,RESOLUTION=640x480,CODECS="avc1.640014,mp4a.40.2"
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:611075
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:00Z
20160607T084833-12-611075.ts
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:10Z
20160607T084833-12-611076.ts
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:20Z
20160607T084833-12-611077.ts
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:30Z
20160607T084833-12-611078.ts
#EXTINF:10.000,
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:40Z
20160607T084833-12-611079.ts
assume that the first 3 slice files "20160607T 084833-12-611075.ts in the current playlist
20160607T084833-12-611076.ts, 20160607T084833-12-611077.ts "are disabled and can be removed. Because the encoding mode of the media stream is not changed, the original encoding mode is still used; but a hop label needs to be added at the updated position: # EXT-X-DISCONTINUITY, and update flag is added: True/False, or 0/1, where True or 0 may represent updated and False or 1 may represent not updated; here, by way of example only, the update flag may be replaced by other indicia and may be placed elsewhere.
The updated playlist is as follows.
(2) Tag updated playlist:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=747800,RESOLUTION=640x480,CODECS="avc1.640014,mp4a.40.2"
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:611075
#EXT-X-DISCONTINUITY
#EXTINF:10.000,True
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:30Z
20160607T084833-12-611078.ts
#EXTINF:10.000,True
#EXT-X-PROGRAM-DATE-TIME:2016-08-17T06:38:40Z
20160607T084833-12-611079.ts
it can be seen that the updated playlist retains two slice files of 20160607T084833-12-611078.ts and 20160607T084833-12-611079.ts, an update mark "True" is added to the identifier at extinnf: 10.000 of the slice file to represent that the slice file is updated, and a jump tag "# EXT-X-DISCONTINUITY" is added before 20160607T084833-12-611078.ts to indicate that the slice file of the current playlist has changed to generate a slice file with a discontinuous timestamp, the parameter value of the tag needs to be reinitialized, if the jump tag is not added, a situation of flashing or instantaneous black screen due to discontinuous slice file occurs, so after the playlist is updated, the tag needs to be updated, thereby ensuring that the video is normally played.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following describes the solution of the present invention in detail with reference to fig. 3a and 3 b.
FIG. 3a is a flow chart of offset correction processing for a current playlist according to an exemplary embodiment of the present invention, which includes;
step 301, acquiring a current play list from a program source server, and turning to step 302;
in this embodiment, the smart tv may obtain a current playlist from the program source server through an http request, where the current playlist is shown as playlist 1 in fig. 3b, where the current playlist includes a tag value and a slice file, i.e., TS files 1-6.
Step 302, judging whether the current playlist needs to be updated, if so, turning to step 303; if not, go to step 304;
the smart television judges whether the current playlist needs to be updated according to the update flag of the previous playlist, for example, when the update flag is 1, the current playlist needs to be updated, and when the update flag is 0, the current playlist does not need to be updated.
Step 303, updating the tag value of the current playlist, and turning to step 304;
when the updating is needed, the smart television can update the EXT-X-DISCONTINUITY label in the current playlist, and the parameter value of the label is initialized again.
Step 304, obtaining the actual playing time, and turning to step 305;
and when the updating is not needed, directly acquiring the synchronous time difference between the intelligent television and the program source server, and taking the sum of the synchronous time difference and the current time as the actual playing time. The synchronous time difference obtained by the intelligent television is assumed to be 5 seconds, and the current local time of the intelligent television is 2017-01-20T10:10: 20; the actual playing time of the slice file of the current playlist is 2017-01-20T10:10: 25.
Step 305, judging whether the slice file is invalid, if so, turning to step 306; if not, go to step 307;
each slice file in the current playlist has a corresponding timestamp, for example, as shown in table 1:
| slice file | Time stamp |
| 1.ts | 2017-01-20T10:10:00 |
| 2.ts | 2017-01-20T10:10:10 |
| 3.ts | 2017-01-20T10:10:20 |
| 4.ts | 2017-01-20T10:10:30 |
| 5.ts | 2017-01-20T10:10:40 |
| 6.ts | 2017-01-20T10:10:50 |
TABLE 1
And comparing the actual playing time of the slice file with the time stamp of the actual playing time, wherein the slice file with the time stamp being earlier than the actual playing time is a failure slice file. For example, the timestamps of 1.ts, 2.ts, and 3.ts are 2017-01-20T10:10:00, 2017-01-20T10:10:10, 2017-01-20T10:10:20, respectively, earlier than the time play time 2017-01-20T10:10:25, so 1.ts, 2.ts, and 3.ts are invalid; and the time stamps of other slice files are not earlier than the playing time, and the slice files are effective.
Step 306, deleting the invalid slice file, updating the tag value of the current playlist, and ending;
the smart television deletes all the invalid slice files to obtain an updated playlist, as shown in the playlist 2 in fig. 3b, where the playlist 2 includes valid slice files, i.e. 4.ts, 5.ts, and 6. ts. While updating the tag value of the playlist.
And 307, analyzing the slice file for playing, and ending.
And analyzing the effective slice file for playing for the user to watch.
Therefore, the invention can achieve the purpose of approximately synchronizing the real-time video streams of different intelligent televisions with the program source server.
Based on the same conception, the invention also provides an offset correction device for the current play list of the intelligent television, which can be realized by software or hardware or a combination of the software and the hardware. Taking software implementation as an example, the offset correction device for the current playlist of the smart television is a logical device, and is formed by reading a corresponding computer program instruction in a memory and then operating through a CPU of a device where the offset correction device is located.
Referring to fig. 4, an offset correction apparatus 500 for a current playlist of a smart tv in an exemplary embodiment of the present invention is shown, where the basic operating environment of the apparatus includes a CPU, a memory and other hardware, and from a logic level, the logical structure of the apparatus 500 is as shown in fig. 5, where:
a time obtaining unit 501, configured to obtain an actual playing time corresponding to a slice file in a current playlist;
a failure determining unit 502, configured to traverse a slice file in a current playlist according to an actual playing time corresponding to the slice file and determine whether a failed slice file exists in the current playlist;
a file deleting unit 503, configured to delete a failed slice file from the current playlist and update the tag value of the current playlist if the failed slice file exists.
Optionally, the time obtaining unit 501 includes:
the first subunit 5011 is configured to acquire a synchronization time difference between the smart television and the program source server;
the second subunit 5012 is configured to configure the sum of the current time of the smart tv and the synchronization time difference as an actual playing time corresponding to the slice file in the current playlist.
Optionally, the first subunit 5011 is specifically configured to send a request packet to a program source server, and record start time of sending the request packet by the smart television; receiving a response message returned by the program source server aiming at the request message, and recording the end time when the smart television receives the response message; and calculating the synchronous time difference between the intelligent television and the program source server according to the starting time and the ending time.
Optionally, the failure determining unit 502 is specifically configured to traverse a current playlist sent by a program source server, where the current playlist includes a slice file and a timestamp of the slice file, and the timestamp is effective playing time set for the slice file by the program source server; and if the time stamp of the slice file is earlier than the actual playing time, the slice file is a failed slice file.
Optionally, the file deleting unit 503 is specifically configured to update an EXT-X-disablement tag of the current playlist, and reinitialize a parameter value.
In summary, the present invention can obtain the actual playing time corresponding to the slice file in the current playlist, traverse the slice file in the current playlist according to the actual playing time corresponding to the slice file, and determine whether there is a failed slice file in the current playlist; and if the invalid slice file exists, deleting the invalid slice file from the current playlist, and updating the tag value of the current playlist. The current play list comprises the time stamp set by the program source server for the slice file, so that the slice file in the current play list and the slice file of the program source server can be played synchronously according to the time stamp, the problem of content deviation caused by transmission time delay and play time delay is solved, the play progress of different intelligent televisions is corrected, and the user experience of the intelligent television user on the live network video stream with higher real-time requirement is improved.
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the application. One of ordinary skill in the art can understand and implement it without inventive effort.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.