Streaming media screenshot method and device
By positioning and downloading the target clip at the time point of the streaming media screenshot and seizing video frames in the clip, the problem of high network traffic and performance consumption of the streaming media screenshot method in the prior art is solved, and efficient streaming media screenshot is achieved.
Patent Information
- Application Number
- CN202411708020.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing streaming screenshot methods require downloading the entire video file, resulting in high network traffic and performance consumption and long download and processing time.
By obtaining the file path of the streaming media and the M3U8 header file, locate and obtain the resource address of the target clip where the screenshot time point is located, download the target clip separately, and capture the video frame corresponding to the screenshot time point in the target clip.
It reduces network traffic and performance consumption, shortens download and processing time, and achieves the purpose of intercepting pictures of streaming media files at specified points in time.
Smart Images

Figure CN119603500A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a streaming media screenshot method and device. Background Art
[0002] With the development of modern technology, the Internet has brought people information in various forms. From the first picture that appeared on the Internet to various forms of online videos and 3D animations today, the Internet has greatly satisfied people's visual and auditory senses. However, before the emergence of streaming media technology, people had to download these multimedia contents to the local computer first and wait for the download to be completed before they could see or hear the information conveyed by the media. After the emergence of streaming media technology, people no longer need to wait for the multimedia content to be downloaded. Among them, streaming media refers to the media format that uses streaming transmission technology to play continuously and in real time on the Internet, such as audio, video or multimedia files. Streaming media technology is also called streaming media technology. The so-called streaming media technology is to compress continuous image and sound information and put it on the website server. The video server transmits each compressed package to the user's computer sequentially or in real time, allowing users to watch and listen while downloading, instead of waiting for the entire compressed file to be downloaded to the computer before watching.
[0003] Due to the superiority of streaming media technology, this technology is widely used in video on demand, video conferencing, distance education, telemedicine and online live broadcast systems. As a symbol of the new generation of Internet applications, streaming media technology has developed rapidly in recent years. During use, users usually need to take screenshots of specified streaming media. The current streaming media screenshot method is mostly to download the complete video file, then use tools such as FFmpeg to process the entire file and capture the video frame at a specified time point. The disadvantage of this method is that it needs to download the entire video file, which will increase network traffic and performance consumption. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention proposes a new streaming media screenshot method and device to solve the technical problems existing in the streaming media screenshot method in the prior art, such as large network traffic and performance consumption, long download and processing time, etc.
[0005] In a first aspect, the present invention provides a streaming media screenshot method, the method comprising: Obtain the file path of the streaming media according to the identifier of the streaming media, and access the preset service according to the file path to obtain the corresponding M3U8 header file; Locate and obtain the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point; Download the target segment separately according to the resource address; A video frame corresponding to the screenshot time point is captured in the target segment.
[0006] Through the embodiments of the present application, it is only necessary to download the target segment at the screenshot time point and capture the video frame corresponding to the screenshot time point in the target segment, thereby being able to achieve the purpose of capturing the image of the streaming media file at a specified time point while reducing network traffic and performance consumption, and can shorten the download and processing time.
[0007] In a technical solution of the above streaming media screenshot method, locating and obtaining the resource address of the target segment at the screenshot time point in the M3U8 header file according to the screenshot time point includes: The target segment at the screenshot time point is calculated according to the screenshot time point and the duration of each segment in the M3U8 header file, and the resource address of the target segment is obtained.
[0008] Through the embodiments of the present application, the target segment at the screenshot time point and the resource address of the target segment can be obtained, so that only the target segment needs to be downloaded according to the resource address, which reduces the file download amount and processing amount, thereby reducing network traffic and performance consumption.
[0009] In a technical solution of the above streaming media screenshot method, locating and obtaining the resource address of the target segment at the screenshot time point in the M3U8 header file according to the screenshot time point also includes: Calculate the position information of the video frame corresponding to the screenshot time point in the target segment according to the screenshot time point and the duration of each segment in the M3U8 header file; The capturing of the video frame corresponding to the screenshot time point in the target segment comprises: The video frame corresponding to the screenshot time point is captured in the target segment according to the position information.
[0010] In a technical solution of the above streaming media screenshot method, the step of capturing a video frame corresponding to the screenshot time point in the target segment includes: Decrypt the target segment using the encryption information corresponding to the M3U8 header file; The video frame corresponding to the screenshot time point is captured from the decrypted target segment.
[0011] In a technical solution of the above streaming media screenshot method, the use of encryption information corresponding to the M3U8 header file to decrypt the target segment includes: Convert the key corresponding to the M3U8 header file into a byte array; A decryptor is created and initialized according to the byte array, and the target segment is decrypted using the decryptor.
[0012] In a technical solution of the streaming media screenshot method, the step of capturing a video frame corresponding to the screenshot time point in the decrypted target segment includes: The decrypted target segment is captured using a preset video converter to obtain a video frame corresponding to the capture time point.
[0013] In a technical solution of the above-mentioned streaming media screenshot method, the preset video converter includes FFmpeg in JavaCV.
[0014] In a technical solution of the above streaming media screenshot method, after capturing the video frame corresponding to the screenshot time point in the target segment, the method further includes: The video frame corresponding to the screenshot time point is uploaded to the preset service for subsequent use.
[0015] In a technical solution of the above streaming media screenshot method, before obtaining the file path of the streaming media according to the identifier of the streaming media, the method further includes: Receiving a screenshot application sent by a target user, wherein the screenshot application carries an identifier of a streaming media to be screenshotted and a screenshot time point; After capturing the video frame corresponding to the screenshot time point in the target segment, the method further includes: The video frame corresponding to the screenshot time point is returned to the target user.
[0016] In a second aspect, the present invention provides a streaming media screenshot device, the device comprising: An acquisition module is used to acquire the file path of the streaming media according to the identifier of the streaming media, and access the preset service according to the file path to acquire the corresponding M3U8 header file; A positioning module, used to locate and obtain the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point; A download module, used to download the target segment separately according to the resource address; The capture module is used to capture the video frame corresponding to the capture time point in the target segment.
[0017] In a third aspect, the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the computer program is executed by the processor, the streaming media screenshot method as described in any one of the first aspects is implemented.
[0018] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein when the computer program is executed, the streaming media screenshot method as described in any one of the first aspects is implemented.
[0019] The above one or more technical solutions of the present invention have at least one or more of the following beneficial effects: In the technical solution of the present invention, the file path of the streaming media is obtained according to the identifier of the streaming media, and the preset service is accessed according to the file path to obtain the corresponding M3U8 header file; the resource address of the target segment where the screenshot time point is located is located in the M3U8 header file according to the screenshot time point and obtained; the target segment is downloaded separately according to the resource address; and the video frame corresponding to the screenshot time point is intercepted in the target segment. The present application solution can achieve the purpose of intercepting the image of the streaming media file at a specified time point while reducing network traffic and performance consumption, and can shorten the download and processing time by only downloading the target segment where the screenshot time point is located and intercepting the video frame corresponding to the screenshot time point in the target segment.
[0020] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The disclosure of the present invention will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. In addition, similar numbers in the figures are used to represent similar components, among which:
[0022] Figure 1 is a flow chart of a streaming media screenshot method provided in Embodiment 1 of the present application; Figure 2 is a flow chart of a streaming media screenshot method provided in Embodiment 2 of the present application; Figure 3 It is a structural diagram of the streaming media screenshot device provided in Example 3 of the present application.
[0023] Figure 4 It is a structural diagram of the computer device provided in Example 4 of the present application. DETAILED DESCRIPTION
[0024] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0025] As described in the background technology, most existing streaming media screenshot methods are to download the complete video file, then use tools such as FFmpeg to process the entire file and capture the video frame at a specified time point. The disadvantage of this method is that the entire video file needs to be downloaded, which increases network traffic and performance consumption.
[0026] Based on this, the present application proposes a method for stream-saving screenshot of M3U8 streaming media files based on JavaCV. This method only needs to download the target segment where the screenshot time point is located, and capture the video frame corresponding to the screenshot time point in the target segment. It can capture images of streaming media files at a specified time point while reducing network traffic and performance consumption, and can shorten the download and processing time.
[0027] Embodiment 1 Figure 1 is a flowchart of a streaming media screenshot method provided in Example 1 of the present application. The method is based on JavaCV technology. Figure 1 As shown, the method comprises the following steps: Step 1: Receive the screenshot request sent by the target user, and obtain the M3U8 header file corresponding to the streaming media according to the screenshot request.
[0028] It can be understood that the embodiment of the present application mainly includes a user side, a transcoding service side, a storage service side and a database, wherein the user side can be a user's mobile phone, computer, pad and other electronic devices, that is, the user can send a screenshot request to the transcoding service side through a mobile phone, computer, pad and other electronic devices.
[0029] It should be noted that in the embodiments of the present application, the types of the transcoding service side, the storage service side, and the database are not specifically limited. When implemented, they can be selected according to the actual business situation. In some specific embodiments, the storage service can be Alibaba Cloud (OSS). The following uses the storage service as Alibaba Cloud (OSS) as an example to illustrate the present application solution.
[0030] As a preferred implementation, in the embodiment of the present application, the screenshot request sent by the target user carries information such as the identifier of the streaming media to be screenshotted and the screenshot time point. It is understandable that after the transcoding service receives the screenshot request sent by the target user, the transcoding service requests the file path of the streaming media from the database according to the identifier of the streaming media, and after receiving the file path of the streaming media returned by the database, the transcoding service requests Alibaba Cloud (OSS) to obtain the corresponding M3U8 header file according to the file path of the streaming media.
[0031] It should be noted that M3U8 refers to an M3U file in UTF-8 encoding format; an M3U file is a plain text file that records an index. When you open it, the playback software does not play it, but finds the network address of the corresponding audio and video file based on its index for online playback. M3U8 is a common streaming media format, which mainly exists in the form of a file list. It supports both live broadcast and on-demand playback, and is most commonly used on platforms such as Android and iOS.
[0032] Step 2: According to the screenshot time point, locate and obtain the resource address of the target segment where the screenshot time point is located in the M3U8 header file.
[0033] In specific implementation, the target segment at the screenshot time point can be calculated based on the screenshot time point and the duration of each segment in the M3U8 header file, and the resource address of the target segment and the position information of the video frame corresponding to the screenshot time point in the target segment can be obtained. The specific calculation process is as follows:
[0034] Iteratively read each fragment in the M3U8 header file, obtain the duration of the current fragment, and determine whether the screenshot time point is in the current fragment. If it is determined that the screenshot time point is in the current fragment, the current fragment is determined as the target fragment. At the same time, the resource address of the current fragment is obtained, the cumulative duration of the read fragments is calculated and the iteration is exited. According to the cumulative duration, the position information of the video frame corresponding to the screenshot time point in the current fragment is obtained.
[0035] It is understandable that in the embodiment of the present application, the type of the resource address of the target segment is not specifically limited, and the user can select it according to actual needs without violating the inventive concept of the present application. As an exemplary and non-restrictive description, the resource address of the target segment in the embodiment of the present application can use a uniform resource locator (URL).
[0036] It should be noted that the Uniform Resource Locator (URL) is a concise representation of the location and access method of resources available on the Internet. It is the address of standard resources on the Internet. Every file on the Internet has a unique URL, which contains information indicating the location of the file and how the browser should handle it. That is, the URL provides an abstract identification method for the location of the resource and uses this method to locate the resource. The basic URL usually contains information such as the mode (or protocol), server name (or IP address), path and file name, which will not be repeated here.
[0037] Step 3: Download the target fragment separately according to the resource address.
[0038] It can be understood that the streaming media screenshot method provided in the embodiment of the present application does not need to download all files like the method in the prior art, but only needs to download the target segment where the screenshot time point is located, and capture the video frame corresponding to the screenshot time point in the target segment. Therefore, it is possible to achieve the purpose of capturing images of streaming media files at a specified time point while reducing network traffic and performance consumption, and can shorten the download.
[0039] Step 4: Decrypt the downloaded target segment using the corresponding encryption information in the M3U8 header file.
[0040] It is understandable that in order to ensure the security of data, the M3U8 header file is usually encrypted, so after downloading the target segment, it needs to be decrypted accordingly. In specific implementation, the key corresponding to the M3U8 header file can be converted into a byte array, and then a decryptor is created and initialized according to the byte array, and the target segment is decrypted using the decryptor.
[0041] It is understandable that the M3U8 header file usually contains information such as the resource URL, arrangement order, encryption method, and key URL. The commonly used encryption method for M3U8 header files is AES-128. AES-128 is the process of encrypting 16-byte data, that is, 128-bit data is converted into another 128-bit data through a series of processes. The key is an indispensable component of AES-128. The key must be expanded first, then changed in rows and columns 10 times, and XORed with the data to finally obtain the encrypted data.
[0042] Step 5: Use the FFmpeg library in JavaCV to process the downloaded clips and capture the video frames at the specified time point.
[0043] In specific implementation, you can first set the offset of the screenshot, then start reading the video stream of the target segment, read the frame at the specified offset, save the screenshot as an image file, and finally stop reading the video stream and release resources.
[0044] It is understandable that JavaCV is a wrapper library based on the JavaCPP calling method (a layer of JNI encapsulation), which consists of a variety of open source computer vision libraries, encapsulating common libraries and utility classes in the field of computer vision, including FFmpeg, OpenCV, tensorflow, caffe, tesseract, libdc1394, OpenKinect, videoInput, and ARToolKitPlus. JavaCV is based on the Apache License Version 2.0 agreement and the GPLv2 agreement. JavaCV supports calling these interfaces on Java platforms including Windows, Linux, MacOS, Android, and IOS.
[0045] In addition, JavaCV also comes with hardware-accelerated full-screen image display (CanvasFrame), easy execution of parallel code in multiple cores (parallelism), user-friendly geometry and color camera and projector calibration, detection and feature points, implementation of projection, camera system and miscellaneous functions in the JavaCV class.
[0046] It is understandable that ffmpeg is a complete solution for video and audio. It provides a series of functions such as video decoding, encoding, and post-processing, and has perfect support for all kinds of video and audio encoding in the world. FFmpeg is developed under the Linux platform, which is completely open source and can also be compiled and run on other platforms. FFmpeg is a cross-platform open source software that can be used for video encoding and decoding. It also provides video and audio conversion, encoding, and packaging functions, as well as a series of post-processing such as video cropping, scaling, and color gamut conversion. Although the operation of converting m3u8 to mp4 using FFmpeg requires the use of the command line, the software is powerful and supports the conversion of various video formats.
[0047] It is understood that in some specific embodiments, after capturing the video frame corresponding to the screenshot time point, the method further includes returning the video frame corresponding to the screenshot time point to the user. In some specific embodiments, after capturing the video frame corresponding to the screenshot time point, the method further includes uploading the captured video frame corresponding to the screenshot time point to Alibaba Cloud OSS or other storage services for subsequent use.
[0048] Embodiment 2 Corresponding to the above-mentioned embodiment 1, the present application also provides a streaming media screenshot method, which is implemented based on JavaCV technology. In this embodiment, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 As shown, the method comprises the following steps:
[0049] S100: acquiring a file path of the streaming media according to an identifier of the streaming media, and accessing a preset service according to the file path to acquire a corresponding M3U8 header file; Specifically, in the embodiments of the present application, the type of the preset service is not specifically limited, and can be selected according to the actual business situation during implementation. In some specific embodiments, the preset service is usually a storage service. As an exemplary and non-restrictive explanation, the preset service in the embodiments of the present application can be Alibaba Cloud (OSS).
[0050] In some specific embodiments, the preset database may be queried according to the identifier of the streaming media to obtain the file path of the streaming media, and then the preset service may be accessed according to the file path to obtain the corresponding M3U8 header file.
[0051] S200: Locate and obtain the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point; It is understandable that the screenshot time point can be given by the requester who issues the screenshot request, or can be arbitrarily specified, and is not specifically limited here.
[0052] It should be noted that in the embodiment of the present application, the type of the resource address of the target segment is not specifically limited, and the user can select it according to actual needs without violating the inventive concept of the present application. As an exemplary and non-restrictive explanation, the resource address of the target segment in the embodiment of the present application can use a uniform resource locator (URL).
[0053] It should be noted that the Uniform Resource Locator (URL) is a concise representation of the location and access method of resources available on the Internet. It is the address of standard resources on the Internet. Every file on the Internet has a unique URL, which contains information indicating the location of the file and how the browser should handle it. That is, the URL provides an abstract identification method for the location of the resource and uses this method to locate the resource. The basic URL usually contains information such as the mode (or protocol), server name (or IP address), path and file name, which will not be repeated here.
[0054] S300: Download the target segment separately according to the resource address; It is understandable that the streaming media screenshot method provided in the embodiment of the present application does not need to download all files like the method in the prior art, but only needs to download the target segment at the screenshot time point, thus reducing network traffic and performance consumption. It can also shorten the download and processing time.
[0055] S400: capturing a video frame corresponding to the screenshot time point in the target segment.
[0056] It can be understood that the streaming media screenshot method provided in the embodiment of the present application can shorten the processing time and improve the screenshot efficiency because it captures the video frame corresponding to the screenshot time point in the target segment.
[0057] As a preferred implementation, in the embodiment of the present application, locating and obtaining the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point includes: The target segment at the screenshot time point is calculated according to the screenshot time point and the duration of each segment in the M3U8 header file, and the resource address of the target segment is obtained.
[0058] In some specific embodiments, the above calculation process can be implemented in the following ways: Iteratively read each fragment in the M3U8 header file, obtain the duration of the current fragment, and determine whether the screenshot time point is in the current fragment. If it is determined that the screenshot time point is in the current fragment, the current fragment is determined as the target fragment. At the same time, the resource address of the current fragment is obtained, the cumulative duration of the read fragments is calculated and the iteration is exited. According to the cumulative duration, the position information of the video frame corresponding to the screenshot time point in the current fragment is obtained.
[0059] As a preferred implementation, in the embodiment of the present application, locating and obtaining the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point also includes: Calculate the position information of the video frame corresponding to the screenshot time point in the target segment according to the screenshot time point and the duration of each segment in the M3U8 header file; The capturing of the video frame corresponding to the screenshot time point in the target segment comprises: The video frame corresponding to the screenshot time point is captured in the target segment according to the position information.
[0060] It can be understood that in the process of locating and obtaining the resource address of the target segment where the screenshot time point is located, the position information of the video frame corresponding to the screenshot time point in the target segment can also be obtained, so as to subsequently capture the video frame corresponding to the screenshot time point in the target segment according to the position information.
[0061] As a preferred implementation, in the embodiment of the present application, the step of capturing the video frame corresponding to the screenshot time point in the target segment includes: Decrypt the target segment using the encryption information corresponding to the M3U8 header file; The video frame corresponding to the screenshot time point is captured from the decrypted target segment.
[0062] As a preferred implementation, in the embodiment of the present application, the use of the encryption information corresponding to the M3U8 header file to decrypt the target segment includes: Convert the key corresponding to the M3U8 header file into a byte array; A decryptor is created and initialized according to the byte array, and the target segment is decrypted using the decryptor.
[0063] It is understandable that in order to ensure the security of data, the M3U8 header file is usually encrypted, so after downloading the target segment, it needs to be decrypted accordingly. In specific implementation, the key corresponding to the M3U8 header file can be converted into a byte array, and then a decryptor is created and initialized according to the byte array, and the target segment is decrypted using the decryptor.
[0064] As a preferred implementation, in the embodiment of the present application, the step of capturing the video frame corresponding to the screenshot time point in the decrypted target segment includes: The decrypted target segment is captured using a preset video converter to obtain a video frame corresponding to the capture time point.
[0065] In specific implementation, you can first set the offset of the screenshot, then start reading the video stream of the target segment, read the frame at the specified offset, save the screenshot as an image file, and finally stop reading the video stream and release resources.
[0066] As a preferred implementation, in the embodiment of the present application, the preset video converter includes FFmpeg in JavaCV. The relevant contents of JavaCV and FFmpeg can refer to the contents in the first embodiment, which will not be repeated here.
[0067] As a preferred implementation, in the embodiment of the present application, after capturing the video frame corresponding to the screenshot time point in the target segment, the method further includes: The video frame corresponding to the screenshot time point is uploaded to the preset service for subsequent use.
[0068] It is understandable that in the embodiments of the present application, the specific use of the video frame corresponding to the screenshot time point is not limited.
[0069] As a preferred implementation, in the embodiment of the present application, before obtaining the file path of the streaming media according to the identifier of the streaming media, the method further includes: Receiving a screenshot application sent by a target user, wherein the screenshot application carries an identifier of a streaming media to be screenshotted and a screenshot time point; After capturing the video frame corresponding to the screenshot time point in the target segment, the method further includes: The video frame corresponding to the screenshot time point is returned to the target user.
[0070] It is understandable that the screenshot request in the embodiment of the present application can be issued by the target user or initiated by the target user, and no specific limitation is made here.
[0071] It is understandable that when the screenshot request is issued by the target user, the screenshot request issued by the target user should carry information such as the identifier of the streaming media to be screenshotted and the screenshot time point, so that the file path and other information of the streaming media can be obtained according to the identifier of the streaming media, and the preset service can be accessed according to the file path to obtain the corresponding M3U8 header file, and the resource address of the target segment where the screenshot time point is located can be located in the M3U8 header file according to the screenshot time point, so that after the target segment is downloaded separately according to the resource address, the video frame corresponding to the screenshot time point can be captured in the target segment.
[0072] Embodiment 3 Corresponding to the above-mentioned embodiments 1 and 2, the present application further provides a streaming media screenshot device, which is used to implement the streaming media screenshot method provided in any one of the embodiments 1 or 2. In this embodiment, the same or similar contents as those in the above-mentioned embodiments 1 or 2 can be referred to the above introduction and will not be described in detail later. Figure 3 As shown, the device comprises:
[0073] An acquisition module 10 is used to acquire a file path of the streaming media according to an identifier of the streaming media, and to access a preset service according to the file path to acquire a corresponding M3U8 header file; A positioning module 20, used to locate and obtain the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point; A download module 30, configured to download the target segment separately according to the resource address; The capture module 40 is used to capture the video frame corresponding to the capture time point in the target segment.
[0074] As a preferred implementation, in the embodiment of the present application, the positioning module is specifically used for: The target segment at the screenshot time point is calculated according to the screenshot time point and the duration of each segment in the M3U8 header file, and the resource address of the target segment is obtained.
[0075] As a preferred implementation, in the embodiment of the present application, the positioning module is further specifically used for: Calculate the position information of the video frame corresponding to the screenshot time point in the target segment according to the screenshot time point and the duration of each segment in the M3U8 header file; The interception module is specifically used for: The video frame corresponding to the screenshot time point is captured in the target segment according to the position information.
[0076] As a preferred implementation, in the embodiment of the present application, the interception module is specifically used for: Decrypt the target segment using the encryption information corresponding to the M3U8 header file; The video frame corresponding to the screenshot time point is captured from the decrypted target segment.
[0077] As a preferred implementation, in the embodiment of the present application, the interception module is specifically used for: Convert the key corresponding to the M3U8 header file into a byte array; A decryptor is created and initialized according to the byte array, and the target segment is decrypted using the decryptor.
[0078] As a preferred implementation, in the embodiment of the present application, the interception module is specifically used for: The decrypted target segment is captured using a preset video converter to obtain a video frame corresponding to the capture time point.
[0079] As a preferred implementation, in the embodiment of the present application, the preset video converter includes FFmpeg in JavaCV.
[0080] As a preferred implementation, in the embodiment of the present application, the device further includes: The feedback module 50 is used to upload the video frame corresponding to the screenshot time point to the preset service for subsequent use.
[0081] As a preferred implementation, in the embodiment of the present application, the device further includes: The receiving module 60 is used to receive a screenshot request sent by a target user, wherein the screenshot request carries an identifier of the streaming media to be screenshotted and a screenshot time point; The feedback module 50 is further configured to return the video frame corresponding to the screenshot time point to the target user.
[0082] Embodiment 4 Corresponding to the above-mentioned embodiment one or two, the present application also provides a computer device, including: a processor and a memory, the memory stores a computer program that can be run on the processor, and when the computer program is executed by the processor, the streaming media screenshot method provided in any one of the above-mentioned embodiments is executed.
[0083] in, Figure 4 The computer device 1500 is shown as an example, and may include a processor 1510, a video display adapter 1511, a disk drive 1512, an input / output interface 1513, a network interface 1514, and a memory 1520. The processor 1510, the video display adapter 1511, the disk drive 1512, the input / output interface 1513, the network interface 1514, and the memory 1520 may be communicatively connected via a communication bus 1530.
[0084] Among them, the processor 1510 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc., to execute relevant programs to implement the technical solution provided by the present invention.
[0085] The memory 1520 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1520 can store an operating system 1521 for controlling the operation of the electronic device and a basic input and output system (BIOS) for controlling the low-level operation of the electronic device. In addition, a web browser 1523, a data storage management system 1524, and a device identification information processing system 1525, etc. can also be stored. The above-mentioned device identification information processing system 1525 can be an application program that specifically implements the operations of the aforementioned steps in the embodiment of the present invention. In short, when the technical solution provided by the present invention is implemented by software or firmware, the relevant program code is stored in the memory 1520 and is called and executed by the processor 1510.
[0086] The input / output interface 1513 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0087] The network interface 1514 is used to connect to a communication module (not shown) to achieve communication interaction between the device and other devices. The communication module can achieve communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0088] The bus includes a path that transmits information between the various components of the device (eg, processor 1510 , video display adapter 1511 , disk drive 1512 , input / output interface 1513 , network interface 1514 , and memory 1520 ).
[0089] In addition, the electronic device can also obtain information on specific collection conditions from the virtual resource object collection condition information database for use in condition judgment, etc.
[0090] It should be noted that, although the above device only shows a processor 1510, a video display adapter 1511, a disk drive 1512, an input / output interface 1513, a network interface 1514, a memory 1520, a bus, etc., in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include components necessary for implementing the solution of the present invention, and does not necessarily include all the components shown in the figure.
[0091] Embodiment 5 Corresponding to the above-mentioned embodiment one or two, the embodiment of the present application further provides a computer-readable storage medium, wherein, in this embodiment, the same or similar contents as those of the above-mentioned embodiment one or two can be referred to the above introduction and will not be repeated later.
[0092] The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the streaming media screenshot method described above is implemented.
[0093] In some implementations, in the embodiments of the present application, when the computer program is executed by the processor, the steps corresponding to the method described in Embodiment 1 may also be implemented. Please refer to the detailed description in Embodiment 1 and no further details will be given here.
[0094] It can be known from the above description of the implementation mode that those skilled in the art can clearly understand that the present invention can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present invention can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention or certain parts of the embodiments.
[0095] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.
[0096] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0097] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0098] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0099] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A streaming media screenshot method, characterized in that: The method comprises: Obtain the file path of the streaming media according to the identifier of the streaming media, and access the preset service according to the file path to obtain the corresponding M3U8 header file; Locate and obtain the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point; Download the target segment separately according to the resource address; A video frame corresponding to the screenshot time point is captured in the target segment.
2. The streaming media screenshot method according to claim 1, characterized in that: The method of locating and obtaining the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point includes: The target segment at the screenshot time point is calculated according to the screenshot time point and the duration of each segment in the M3U8 header file, and the resource address of the target segment is obtained.
3. The streaming media screenshot method according to claim 2, characterized in that: The method of locating and obtaining the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point also includes: Calculate the position information of the video frame corresponding to the screenshot time point in the target segment according to the screenshot time point and the duration of each segment in the M3U8 header file; The capturing of the video frame corresponding to the screenshot time point in the target segment comprises: The video frame corresponding to the screenshot time point is captured in the target segment according to the position information.
4. The streaming media screenshot method according to claim 1, characterized in that: The capturing of the video frame corresponding to the screenshot time point in the target segment includes: Decrypt the target segment using the encryption information corresponding to the M3U8 header file; The video frame corresponding to the screenshot time point is captured from the decrypted target segment.
5. The streaming media screenshot method according to claim 4, characterized in that: The decrypting the target segment using the encryption information corresponding to the M3U8 header file includes: Convert the key corresponding to the M3U8 header file into a byte array; A decryptor is created and initialized according to the byte array, and the target segment is decrypted using the decryptor.
6. The streaming media screenshot method according to claim 4, characterized in that: The step of capturing a video frame corresponding to the screenshot time point in the decrypted target segment includes: The decrypted target segment is captured using a preset video converter to obtain a video frame corresponding to the capture time point.
7. The streaming media screenshot method according to claim 6, characterized in that: The preset video converter includes FFmpeg in JavaCV.
8. The streaming media screenshot method according to any one of claims 1 to 7, characterized in that: After capturing the video frame corresponding to the screenshot time point in the target segment, the method further includes: The video frame corresponding to the screenshot time point is uploaded to the preset service for subsequent use.
9. The streaming media screenshot method according to any one of claims 1 to 7, characterized in that: Before obtaining the file path of the streaming media according to the identifier of the streaming media, the method further includes: Receiving a screenshot application sent by a target user, wherein the screenshot application carries an identifier of a streaming media to be screenshotted and a screenshot time point; After capturing the video frame corresponding to the screenshot time point in the target segment, the method further includes: The video frame corresponding to the screenshot time point is returned to the target user.
10. A streaming media screenshot device, characterized in that: The device comprises: An acquisition module is used to acquire the file path of the streaming media according to the identifier of the streaming media, and access the preset service according to the file path to acquire the corresponding M3U8 header file; A positioning module, used to locate and obtain the resource address of the target segment where the screenshot time point is located in the M3U8 header file according to the screenshot time point; A download module, used to download the target segment separately according to the resource address; The capture module is used to capture the video frame corresponding to the capture time point in the target segment.
Citation Information
Patent Citations
Streaming media display method and equipment and system
CN102843614A
Video file downloading method, device, server and terminal equipment
CN105100839A
Live streaming data processing method and device
CN106603503A
Video playing method and system, electronic equipment and storage medium
CN115225934A
Video frame cutting method and device
CN117319748A