CN116567359A - Method for positioning progress based on TS file on demand - Google Patents
Method for positioning progress based on TS file on demand Download PDFInfo
- Publication number
- CN116567359A CN116567359A CN202310513550.2A CN202310513550A CN116567359A CN 116567359 A CN116567359 A CN 116567359A CN 202310513550 A CN202310513550 A CN 202310513550A CN 116567359 A CN116567359 A CN 116567359A
- Authority
- CN
- China
- Prior art keywords
- file
- time
- progress
- converted
- demand
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 34
- 230000009191 jumping Effects 0.000 claims abstract description 11
- 238000004364 calculation method Methods 0.000 claims description 8
- 238000005070 sampling Methods 0.000 claims description 3
- 230000002123 temporal effect Effects 0.000 claims description 3
- 238000004590 computer program Methods 0.000 description 7
- 238000010586 diagram Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 4
- 239000000284 extract Substances 0.000 description 3
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/47—End-user applications
- H04N21/472—End-user interface for requesting content, additional data or services; End-user interface for interacting with content, e.g. for content reservation or setting reminders, for requesting event notification, for manipulating displayed content
- H04N21/47217—End-user interface for requesting content, additional data or services; End-user interface for interacting with content, e.g. for content reservation or setting reminders, for requesting event notification, for manipulating displayed content for controlling playback functions for recorded or on-demand content, e.g. using progress bars, mode or play-point indicators or bookmarks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/70—Information retrieval; Database structures therefor; File system structures therefor of video data
- G06F16/71—Indexing; Data structures therefor; Storage structures
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/80—Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
- H04N21/83—Generation or processing of protective or descriptive data associated with content; Content structuring
- H04N21/845—Structuring of content, e.g. decomposing content into time segments
- H04N21/8455—Structuring of content, e.g. decomposing content into time segments involving pointers to the content, e.g. pointers to the I-frames of the video stream
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Databases & Information Systems (AREA)
- Signal Processing (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
Abstract
The invention discloses a method based on TS file on-demand positioning progress in the field of streaming media information, and aims to solve the technical problem that the time for jumping on-demand progress of a TS file is too long. It comprises the following steps: sequentially reading TS data packets in a TS file, and extracting PES data packets from the TS data packets; if the frame type of the PES data packet is a video key frame, acquiring a starting position P of a binary byte of the corresponding TS data packet and a time T of the starting position, and converting the T into a combination form of integer minutes and milliseconds; converting P and the converted T into a form of a comparison table, and writing the comparison table into a pre-constructed video frame index table S; when a TS file is played on demand, converting the time of the needed jump into a combined form of integer minutes and milliseconds, searching a video frame index table S to acquire T closest to the time of the progress, and finding P to be the play-on-demand jump point; the method solves the problem that the on-demand progress skip of the TS file is long and time-consuming, and greatly reduces the waiting time required by the progress skip in the on-demand process.
Description
Technical Field
The invention relates to a method for positioning progress based on TS file on demand, belonging to the technical field of streaming media information.
Background
In the field of streaming media, a common file storage form based on an HLS protocol is in a TS form, and for long-time recording scenes, in order to control the number of TS files, the file size is usually larger, so that on-demand progress jumping of the TS files is usually a longer time-consuming operation, and the problems of too long waiting time, lower working efficiency and the like of progress jumping in the on-demand process are caused.
Disclosure of Invention
The invention aims to overcome the defects in the prior art, and provides a method based on TS file on-demand positioning progress, which effectively solves the problem that the on-demand progress jumping of TS files is long and time-consuming, and greatly reduces the waiting time required by the progress jumping in the on-demand process.
In order to achieve the above purpose, the invention is realized by adopting the following technical scheme:
the invention provides a method for positioning progress based on TS file on demand, which comprises the following steps:
sequentially reading TS data packets in a TS file, and extracting PES data packets from the TS data packets;
if the frame type of the PES data packet is a video key frame, acquiring a corresponding starting position P of a binary byte of the TS data packet and time T of the starting position P, and converting the T into a combination form of integer minutes and milliseconds;
converting P and the converted T into a form of a comparison table, and writing the comparison table into a pre-constructed video frame index table S;
when a TS file is played, the required jumping progress time is converted into a combination form of integer minutes and milliseconds, a video frame index table S is searched according to the converted progress time, T closest to the progress time is obtained, and P corresponding to the T is used as a playing jumping point.
Further, when the P and the converted T are converted into the form of the comparison table and written into the pre-constructed video frame index table S, the integer minutes in the converted T are used as the marks G of the corresponding comparison table, and the marks G are used to associate the comparison table.
Further, when the reference table is written into the video frame index table S, if the reference table is marked G, the reference table is associated with the existing mark G, and if the reference table is not marked G, the reference table is newly created.
Further, searching the video frame index table S according to the converted progress time to obtain the T closest to the progress time, including:
searching a video frame index table S, and obtaining a mark G corresponding to the converted progress time integer minutes;
all the lookup tables associated with the mark G are acquired, and T which is closest to the converted progress time millisecond is acquired.
Further, the time T is calculated by:units: ms; wherein T is n Time T, DTS representing the start position P of binary bytes of TS packets of an nth video key frame n Representing T n DTS field of the nth video key frame; DTS (digital television System) 1 Representing T 1 DTS field of the 1 st video key frame; timebase represents the temporal basis of the current video sampling rate.
Further, the calculation method for converting T into the combination of integer minutes and milliseconds is as follows:
wherein T is n Mod represents the remainder at the corresponding point in time of the start position P of the binary byte of the TS packet representing the nth video key frame; MT (Mobile telephone) n Representing T n Is a part of the minute; ST (ST) n Representing T n Is a millisecond part of (2).
Further, the read TS file comprises a TS file or an existing TS file in the recording process.
Compared with the prior art, the invention has the beneficial effects that:
the invention provides a method based on TS file on-demand positioning progress, which uses the creation of a video frame index table, reads TS data packets in a TS file, extracts PES data packets, converts the frame type of the PES data packets into the form of a binary byte starting position P and corresponding time T of the TS data packets of a video key frame, converts the binary byte starting position P and MT of the TS data packets of the video key frame into a form of a comparison table, writes the form of the comparison table into the video frame index table S, and converts the time of the progress of the needed skip into the form of the needed integer minutes plus the needed residual milliseconds when the on-demand TS file is carried out; inquiring and matching according to the video frame index table S to obtain a mark G corresponding to the MT; and (3) obtaining the TS data packet with the matching of all the comparison tables in the G to the TS data packet closest to the millisecond, obtaining the binary byte starting position P of the TS data packet in the TS file, and normally reading the PES data packet for playing after pointing the binary byte stream index of the TS file to the P, thereby solving the problem of long time consumption of the on-demand progress skip of the TS file and greatly reducing the waiting time required by the progress skip in the on-demand process.
Drawings
FIG. 1 is a flow chart of a method for positioning progress based on TS file on demand according to the present invention;
FIG. 2 is a schematic diagram of the method of FIG. 1;
FIG. 3 is a data format of a TS file;
FIG. 4 is a first portion of a PES packet;
FIG. 5 is a second portion of a PES packet;
FIG. 6 is a third portion of a PES packet;
FIG. 7 is a fourth portion of a PES packet;
fig. 8 is a fifth portion of a PES packet.
Detailed Description
The invention is further described below with reference to the accompanying drawings. The following examples are only for more clearly illustrating the technical aspects of the present invention, and are not intended to limit the scope of the present invention.
Embodiment one:
referring to fig. 1 to 8, a method for positioning progress based on a TS file on demand includes the following steps:
step one: sequentially reading TS data packets in a TS file, and extracting PES data packets from the TS data packets;
wherein, the step of creating the video frame index table S includes:
(1.1) creating an index table file: file.tsi;
(1.2) writing the ts file name with UTF-8 code and wrapping;
(1.3) writing the first minute mark content: "group 1" and line feed;
(1.4) creating the index table is completed.
Step two: if the frame type of the PES data packet is a video key frame, acquiring a starting position P and a starting position time T of a binary byte of the corresponding TS data packet, and converting the T into integer minutes and milliseconds. If the frame type of the PES data packet is not the video key frame, skipping to the next TS data packet in the TS file, and extracting the corresponding PES data packet.
First, time T n The calculation mode of (a) is as follows:
units: ms; wherein T is n Time T representing binary byte start position P of TS packet of nth video key frame; DTS (digital television System) n Representing T n DTS field of the nth video key frame; DTS (digital television System) 1 Representing T 1 DTS field of the 1 st video key frame; timebase represents the temporal basis of the current video sampling rate.
Next, T is used n Integer minutes MT for calculating the progress time of a desired jump n And the remaining millimeter ST n The calculation mode of (a) is as follows:
wherein T is n The start position P of binary bytes of TS packets representing the nth video key frame n Corresponding time points of (a); mod represents the remainder; MT (Mobile telephone) n Representing T n Is the nth minute portion of (2); ST (ST) n Representing T n Is the nth millisecond portion of (2).
Step three: converting the P and the converted T into a form of a comparison table, and writing the comparison table into a pre-constructed video frame index table S, wherein the method specifically comprises the following steps of: when the integer minutes of P and the converted T are converted into the form of a comparison table and written into a pre-constructed video frame index table S, the integer minutes in the converted T are used as marks G of the corresponding comparison table, and the marks G are used for associating the comparison table. One G is marked every one minute.
When the reference table is written into the video frame index table S, if the mark G of the reference table exists, the existing mark G is used for associating the reference table, and if the mark G does not exist, the mark G of the reference table is newly established.
For example, in adding ST 1 To judge G 1 If not, the mark G is written in the video frame index table S 1 When writing ST 2 Is determined to have G 1 The marking is not repeated.
Step four: when a TS file is played, the required jumping progress time is converted into a combination form of integer minutes and milliseconds, a video frame index table S is searched according to the converted progress time, T closest to the progress time is obtained, and P corresponding to the T is used as a playing jumping point.
The method specifically comprises the following steps:
searching a video frame index table S, and obtaining a mark G corresponding to the converted progress time integer minutes; and (3) acquiring all the comparison tables associated with the marks G, acquiring the T closest to the converted progress time millisecond, finding the binary byte starting position P of the binary byte starting position P in the TS file, pointing the binary byte stream index of the TS file to the starting position P, and then normally reading the PES data packet for playing.
In fig. 2: 1. the TS file (1) is a data packet of the TS file which needs to be requested; 2. (2) is a data component of a TS file; 3. the video key frame (3) is a key video data frame coded by H.264 or H.265; 4. the video non-key frames (4) are non-key video data frames encoded by H.264 or H.265; 5. the audio frame (5) is an audio data frame subjected to audio encoding; 6. the video index table (6) is a time position comparison index table and is used for rapidly positioning the file progress; 7. the mark (7) is a mark for grouping the time position reference indexes by minutes; 8. time (8) is the total milliseconds of the relative time of the corresponding TS packets divided by minutes; 9. the file location (9) is the starting binary byte position in the file corresponding to the TS packet; 10. the TS packet time (d) is the relative time calculated by the DTS for the TS packet.
The read TS file comprises a TS file in the recording process or an existing TS file, and is implemented by the following two embodiments.
Embodiment two:
combining the method based on the TS file on-demand positioning progress of the first embodiment, the step of thinning the TS file in the recording process and establishing the video frame index table S in the embodiment:
the first step: a video frame index table S is created.
And a second step of: a TS file is created.
And a third step of: a TS file writing position TP and a video frame index writing position SP are defined.
Fourth step: receiving first packet TS data TS 1 And extracts PES packet F therefrom 1 . Wherein the TS data structure is shown in FIG. 2.
Fifth step: judgment F 1 Whether it is a video key frame, if F 1 If not, the process jumps to the ninth step.
Sixth step: if F 1 Is a video key frame, obtain F 1 Calculated relative time T for DTS field of (2) 1 The PES data structure is shown in fig. 3.T (T) n The calculation mode of (a) is as follows:where n represents the nth frame, timebase represents the time base of the current video sample rate, T n Is in milliseconds.
Seventh step: using T 1 Calculate the belonging minutes MT 1 And the remaining number of milliseconds ST 1 The calculation formula is as follows:where n represents the nth frame. Judging whether MT exists in S 1 The label G of (2) 1 The method comprises the steps of carrying out a first treatment on the surface of the If not, writing in the writing position SP in the video frame index table S, andthe writing position SP is moved backward by the total writing length.
Eighth step: the writing position SP in the video frame index table S is written with TP and SP is moved backward to write the total length.
Ninth step: writing in the TS file at the writing position TP, and moving the writing position TP backward for writing total length.
Tenth step: and receiving the TS data packet of the next packet, and repeating the fourth step to the ninth step until all data are received.
Embodiment III:
the method based on TS file on-demand positioning progress of the first embodiment is combined, and the first embodiment is refined. Compared with the second embodiment, the present embodiment performs index table making for the existing ts file, and establishes the video frame index table S:
the first step: a video frame index table S is created.
And a second step of: reading data packet TS from TS file according to TS packet format 1 Record TS 1 Start position P in TS file 1 。
And a third step of: parsing TS 1 And extracts PES packet F therefrom 1 。
Fourth step: judgment F 1 Whether it is a video key frame, if F 1 Is a video key frame, obtain F 1 Calculated relative time T for DTS field of (2) 1 The PES data structure is shown in fig. 3.T (T) 1 The calculation mode of (a) is as follows:where n represents the nth video key frame, timebase represents the time base of the current video sample rate, T n Is in milliseconds.
Fifth step: using T 1 Calculate the belonging minutes MT 1 And the remaining number of milliseconds ST 1 The calculation formula is as follows:judging whether MT exists in S 1 The label G of (2) 1 If not, write in SG 1 。
Sixth step: writing ST in S 1 And P 1 。
Seventh step: reading the next TS data packet from TS file, and recording TS 2 Start position P in TS file 2 。
Eighth step: repeating the third step to the seventh step until the TS files are completely read.
Ninth step: the time T at which the jump is required is obtained.
Tenth step: according to T n Calculate the belonging minutes MT n And the remaining millimeter ST n 。
Eleventh step: opening a video frame index table S, reading all data in the video frame index table S, grouping by taking the marks as grouping basis, and finding out the MT n Corresponding mark G n 。
Twelfth step: traversing all data contained in G in turn and finding out the closest ST n TS of (2) n And obtaining a corresponding starting position P by the data packet.
Thirteenth step: and opening the TS file, setting a starting position P of binary bytes of a TS data packet of a video key frame, reading the file, and reading a PES data packet for on-demand.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and variations could be made by those skilled in the art without departing from the technical principles of the present invention, and such modifications and variations should also be regarded as being within the scope of the invention.
Claims (7)
1. The method for positioning progress based on TS file on demand is characterized by comprising the following steps:
sequentially reading TS data packets in a TS file, and extracting PES data packets from the TS data packets;
if the frame type of the PES data packet is a video key frame, acquiring a corresponding starting position P of a binary byte of the TS data packet and time T of the starting position P, and converting the T into a combination form of integer minutes and milliseconds;
converting P and the converted T into a form of a comparison table, and writing the comparison table into a pre-constructed video frame index table S;
when a TS file is played, the required jumping progress time is converted into a combination form of integer minutes and milliseconds, a video frame index table S is searched according to the converted progress time, T closest to the progress time is obtained, and P corresponding to the T is used as a playing jumping point.
2. The method of claim 1, wherein converting P and converted T into a form of a lookup table to be written into a pre-constructed video frame index table S comprises: when P and the converted T are converted into the form of a comparison table and written into a pre-constructed video frame index table S, the integer minutes in the converted T are used as marks G of the corresponding comparison table, and the marks G are used for associating the comparison table.
3. The method according to claim 3, wherein when the reference table is written into the video frame index table S, if the reference table flag G exists, the reference table is associated with the existing flag G, and if the reference table flag G does not exist, the reference table flag G is newly created.
4. The method for positioning progress on demand of TS file according to claim 4 wherein searching the video frame index table S according to the converted progress time to obtain T closest to the progress time comprises:
searching a video frame index table S, and obtaining a mark G corresponding to the converted progress time integer minutes;
all the lookup tables associated with the mark G are acquired, and T which is closest to the converted progress time millisecond is acquired.
5. The method of positioning progress based on TS file on demand according to claim 1, wherein the time T of the starting position is calculated by:wherein T is n Time of binary byte start position P of TS packet representing nth video key frame, DTS n A DTS field representing an nth video key frame; DTS (digital television System) 1 A DTS field representing the 1 st video key frame; timebase represents the temporal basis of the current video sampling rate.
6. The method of positioning progress based on TS file on demand according to claim 1, wherein the calculation mode of converting T into a combination of integer minutes and milliseconds is:wherein T is n Time of binary byte start position P of TS packet representing nth video key frame, mod represents the remainder; MT (Mobile telephone) n Representing T n Is a part of the minute; ST (ST) n Representing T n Is a millisecond part of (2).
7. The method of claim 1, wherein the TS file read comprises a TS file during recording or an existing TS file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310513550.2A CN116567359A (en) | 2023-07-04 | 2023-07-04 | Method for positioning progress based on TS file on demand |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310513550.2A CN116567359A (en) | 2023-07-04 | 2023-07-04 | Method for positioning progress based on TS file on demand |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116567359A true CN116567359A (en) | 2023-08-08 |
Family
ID=87499565
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310513550.2A Pending CN116567359A (en) | 2023-07-04 | 2023-07-04 | Method for positioning progress based on TS file on demand |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116567359A (en) |
-
2023
- 2023-07-04 CN CN202310513550.2A patent/CN116567359A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4598627B2 (en) | Content editing apparatus and playback apparatus thereof | |
US9870799B1 (en) | System and method for processing ancillary data associated with a video stream | |
US20050228861A1 (en) | Minute file creation method, minute file management method, conference server, and network conference system | |
CA2558392C (en) | Method, devices, system and software product for compressed-domain video editing | |
CN106792152B (en) | Video synthesis method and terminal | |
JP2007012112A (en) | Data recording device and method thereof, program, and recording medium | |
CN103081488A (en) | Signaling video samples for trick mode video representations | |
CN1292144A (en) | Signal processing on information files so as to obtain characteristic point information sequences | |
CN112087642B (en) | Cloud guide playing method, cloud guide server and remote management terminal | |
CN109511008B (en) | Method for supporting video and audio file content addition based on object storage | |
CN104780456A (en) | Video dotting and playing method and device | |
KR101432994B1 (en) | Method for creating and reproducing media metadata based on media object and apparatus thereof | |
CN102682016B (en) | A kind of directory system and method for supporting MOV/3GP/MP4 files | |
CN116567359A (en) | Method for positioning progress based on TS file on demand | |
JP2006333330A (en) | Data processing method, and apparatus and program | |
CN101340570B (en) | Method for realizing redirection when playing stream media | |
CN114786065B (en) | FFmpeg-based HLS video playing progress accurate switching method | |
CN102118633A (en) | Method, device and system for playing video files | |
CN102376333B (en) | Multimedia playing terminal and method and device for playing multimedia files | |
KR100789380B1 (en) | Interactive Contents Terminal Wherein Object of Media Data Can Be Substituted | |
CN102387177A (en) | Method and device for downloading audio-visual files | |
CN102231847B (en) | Direct and accurate frame positioning method supporting stream media files | |
US20070146803A1 (en) | Information recording apparatus and recorded information management method | |
CN114025196B (en) | Encoding method, decoding method, encoding/decoding device, and medium | |
CN113206853B (en) | Video correction result storage improvement method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |