Video frame extraction method, device and equipment and computer storage medium
Through preset interval frame extraction and frame rate condition judgment, combined with automatic CPU/GPU resource switching, the problem of large hardware resource occupation in the existing technology is solved, and efficient video frame extraction and widely applicable effects are achieved.
Patent Information
- Application Number
- CN202311723572.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-14
- Publication Date
- 2024-10-22
AI Technical Summary
Existing video frame extraction technology occupies a large amount of hardware resources and cannot effectively save CPU/GPU resources. Moreover, existing automation solutions are costly and cannot be widely used.
Use the preset interval frame extraction method to record key frames and target frames, and decide whether to decode according to the frame rate conditions. If the conditions are not met, neighbor key frames will be used to replace the target frame output, and the decoding method will be automatically switched when CPU/GPU resources are available. Improve efficiency.
It effectively saves CPU/GPU resources, improves the efficiency of video frame extraction, reduces hardware assistance requirements, and is suitable for a wide range of intelligent analysis scenarios.
Smart Images

Figure CN118828056A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of video processing, and in particular to a video frame extraction method, device, equipment and medium. Background Art
[0002] With the rapid development of artificial intelligence technology, it has been widely used in the video field, and the country and governments at all levels are also actively promoting public security based on artificial intelligence. In addition to providing basic functions such as real-time monitoring and recording, industry video surveillance often needs to provide value-added services such as face recognition, vehicle recognition, crowd gathering, and fight recognition. However, video intelligent analysis takes up a lot of hardware resources and cannot process every frame of the video source. It is necessary to extract frames at a certain interval and then pass them to the intelligent analysis service. Specifically, a typical frame extraction process can be referred to as follows Figure 1 As shown in the figure: first, the video stream or file is decapsulated to obtain the encoded video frame, and then decoded in sequence to obtain the YUV video frame, and then the YUV video frame is sampled at intervals, and finally the sampled frame is encoded into a JPEG image and passed to the intelligent analysis service.
[0003] In the process of implementing the solution of the present application, the inventors found that decoding resources are the biggest bottleneck of the frame extraction service. The above-mentioned typical frame extraction process requires decoding each encoded video frame in the video stream to obtain a YUV video frame. However, decoding all compressed data in the video stream will take up a lot of CPU / GPU resources, and most of the decoded image data is directly discarded. Only a few images are selected and compressed into JPEG pictures as the frame extraction result, resulting in a waste of resources.
[0004] In one prior art, a user can select a target preview image from candidate preview images to determine the extracted frame image. However, in the process of implementing the present application scheme, the inventor found that although this prior scheme can better determine the extracted frame image, it introduces human selection factors, cannot be processed automatically, cannot be widely used, and is not used in intelligent analysis scenarios.
[0005] In another prior art, the frame extraction frequency can be determined according to the motion state information, and then the video stream of the target object can be extracted according to the frame extraction frequency, so that computing resources can be saved when the target object moves slowly. However, the inventor found in the process of implementing the solution of this application that in this existing solution, the determination of the motion state requires additional wearable equipment, the system is more dependent, the cost is high, and it is not worth widespread application. Summary of the invention
[0006] The embodiments of the present application provide a video frame extraction method, apparatus, device and computer storage medium to provide a video frame extraction solution that can not only avoid excessive occupation of decoding resources but also be widely applicable.
[0007] In a first aspect, an embodiment of the present application provides a video frame extraction method, the method comprising:
[0008] Extract frames from the input video stream at a preset interval. During the frame extraction process, the most recently encountered key frame is recorded as the current key frame, and the most recently extracted target frame is recorded as the current target frame;
[0009] Determine whether the position of the current target frame, the position of the current key frame and the current average frame rate meet the specified conditions;
[0010] If the specified conditions are met, the current key frame is decoded and output instead of the current target frame;
[0011] If the specified condition is not met, determine whether a key frame is encountered in the specified number of video frames after the current target frame. If a key frame is encountered, the encountered key frame will be output instead of the current target frame. If no key frame is encountered, the current target frame and the video frames between the current target frame and the current key frame will be decoded in sequence, and the current target frame will be output based on the decoding.
[0012] In a second aspect, an embodiment of the present application provides a video frame extraction device, the device comprising:
[0013] A frame extraction module is used to extract frames from the input video stream according to a preset interval;
[0014] A recording module, used for recording the latest encountered key frame as the current key frame and the latest extracted target frame as the current target frame during the frame extraction process of the frame extraction module;
[0015] The replacement output module is used to determine whether the position of the current target frame, the position of the current key frame and the current average frame rate meet the specified conditions; if the specified conditions are met, the current key frame is decoded and outputted instead of the current target frame; if the specified conditions are not met, it is determined whether a key frame is encountered in the video frames within a specified number after the current target frame. If a key frame is encountered, the encountered key frame is outputted instead of the current target frame; if no key frame is encountered, the current target frame and the video frames between the current target frame and the current key frame are decoded in sequence, and the current target frame is outputted based on the decoding.
[0016] In a third aspect, an embodiment of the present application provides a computer storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the video frame extraction method of the first aspect is implemented.
[0017] In a fourth aspect, an embodiment of the present application further provides a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the video frame extraction method of the first aspect.
[0018] The video frame extraction method provided by the embodiment of the present application extracts frames from the input video stream according to a preset interval. During the frame extraction process, the most recently encountered key frame is recorded as the current key frame, and the most recently extracted target frame is recorded as the current target frame; it is determined whether the position of the current target frame, the position of the current key frame, and the current average frame rate meet the specified conditions; if the specified conditions are met, the current key frame is decoded and output instead of the current target frame; if the specified conditions are not met, it is determined whether a key frame is encountered in the video frames within a specified number after the current target frame, if a key frame is encountered, the encountered key frame is output instead of the current target frame, if no key frame is encountered, the current target frame and the video frames between the current target frame and the current key frame are decoded in sequence, and the current target frame is output based on the decoding. The method provided by the embodiment of the present application is a method of incomplete decoding frame extraction, which does not require complex decoding output for each extracted target frame, but in some cases uses a neighbor key frame to directly replace the target frame decoding output, so that while ensuring the approximate accuracy of the frame extraction image, it not only greatly improves the efficiency of frame extraction decoding, but also does not require other hardware assistance, and has a wide range of applicability.
[0019] In addition, when both CPU and GPU resources exist in the system, in order to make full use of CPU / GPU computing resources while ensuring stable operation of the system, the method provided in the embodiment of the present application can realize automatic switching between CPU decoding frame extraction and GPU decoding frame extraction based on the decoding ratio in incomplete decoding frame extraction and CPU utilization, thereby achieving the effect of efficient decoding frame extraction using both CPU and GPU at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0021] Figure 1 It is a typical video frame extraction process diagram in the prior art;
[0022] Figure 2 It is a flowchart of a video frame extraction method provided by an embodiment of the present application;
[0023] Figure 3 It is a flowchart of a video frame extraction method in a specific application example;
[0024] Figure 4 It is a structural schematic diagram of a video frame extraction device provided by an embodiment of the present application;
[0025] Figure 5 It is a schematic diagram of the hardware structure of the terminal device involved in the embodiment of the present application. DETAILED DESCRIPTION
[0026] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0027] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0028] After video encoding, it is divided into I-frame, P-frame and B-frame. I-frame stands for key frame or intra-frame. I-frame is obtained by image compression and spatial prediction of the original captured image, which can be decoded independently. P-frame stands for predicted frame. In addition to spatial prediction, it is also compressed by temporal prediction (using the redundancy of previous and next images). The previous frame needs to be decoded before the current P-frame can be decoded. B-frame stands for bidirectional prediction frame, which refers to the frames before and after it. The typical video frame extraction process can be seen in Figure 1 shown.
[0029] Decoding resources are the biggest bottleneck of the frame extraction service. In the process of implementing the present application scheme, the inventors found that if a predicted frame is extracted, the decoding process is more complicated and time-consuming. At this time, if it can be replaced with a key frame, since the key frame can be decoded independently, the decryption process is relatively simple, and the efficiency of frame extraction decoding can be greatly improved.
[0030] Based on this, in order to solve the problems in the prior art, an embodiment of the present application provides a video frame extraction method. Figure 2 A schematic flow chart of a video frame extraction method provided in one embodiment of the present application is shown.
[0031] refer to Figure 2 As shown, the method may include:
[0032] In step S201, the input video stream is frame extracted at a preset interval. During the frame extraction process, the most recently encountered key frame is recorded as the current key frame, and the most recently extracted target frame is recorded as the current target frame.
[0033] After the frame extraction task is started, the input video stream begins to be received and frames are extracted at preset intervals.
[0034] As an example, the preset interval may specifically include: a video frame number interval or a time interval. This embodiment does not limit the specific preset interval, and those skilled in the art may select and design it according to different requirements and scenarios. These selections and designs that can be used here do not deviate from the spirit and protection scope of this application.
[0035] In this embodiment, each input video frame is judged in turn during the frame extraction process. In addition to judging whether each video frame is the target frame to be extracted and recording the latest extracted target frame as the current target frame (recording its position as K), it is also necessary to record each time a new key frame is encountered as the current key frame and record its position L.
[0036] In step S202, it is determined whether the position of the current target frame, the position of the current key frame and the current average frame rate meet specified conditions.
[0037] In step S203, if the specified condition is met, the current key frame is decoded and outputted instead of the current target frame;
[0038] If the specified condition is not met, determine whether a key frame is encountered in the specified number of video frames after the current target frame. If a key frame is encountered, the encountered key frame will be output instead of the current target frame. If no key frame is encountered, the current target frame and the video frames between the current target frame and the current key frame will be decoded in sequence, and the current target frame will be output based on the decoding.
[0039] In some implementations, the specified conditions may specifically include:
[0040] |KL|<δ*F, where K is the position of the current target frame, L is the position of the current key frame, F is the current average frame rate, and δ is the adjustment factor, with a value range of [0,1).
[0041] Correspondingly, the specified quantity may specifically include: δ*F.
[0042] In some cases, the extracted target frame will not be decoded and output, but its neighbor key frame will be decoded and output, that is, the predicted frame that should be output is replaced by the key frame for output, thereby improving the decoding efficiency. In other cases, when replacement is not possible, the target frame will be decoded and output.
[0043] As an example, the current average frame rate specifically includes:
[0044] The average frame rate during the specified time period before the current keyframe.
[0045] This embodiment does not limit the definition of the current average frame rate and the provisions of the specified time period. Technical personnel in this field can make their own choices and designs based on different needs and scenarios. These choices and designs that can be used here do not deviate from the spirit and protection scope of this application.
[0046] The method provided in this embodiment is an incomplete decoding frame extraction method. It does not need to perform complex decoding output on each extracted target frame. Instead, in some cases, neighbor key frames are used to directly replace the target frame decoding output. This greatly improves the efficiency of frame extraction decoding while ensuring the approximate accuracy of the extracted frame image. It also does not require other hardware assistance and has wide applicability.
[0047] In addition, in some application scenarios, in order to make better use of computing resources, the automatic switching from CPU decoding frame extraction to GPU decoding frame extraction can be achieved based on the decoding ratio and CPU utilization in incomplete decoding frame extraction, and the CPU and GPU can be used for simultaneous decoding frame extraction.
[0048] Therefore, the method may also include:
[0049] The total number of frames processed is T f , and the cumulative number of decoded frames D when the current target frame and the video frames between the current target frame and the current key frame are decoded in sequence f ;
[0050] Calculate the current T with the specified period f and D f The ratio D p , and obtain the current CPU usage U c ;
[0051] According to D p and U c , switch between using CPU decoding and GPU decoding.
[0052] For example, according to D p and Uc , switching between using CPU decoding and GPU decoding can include:
[0053] When D p is less than the first preset value and U c When it is less than a second preset value, CPU decoding and frame extraction are disabled and GPU decoding and frame extraction are enabled.
[0054] In practical applications, the first preset value and the second preset value may be defined by a technician, and this embodiment does not limit this.
[0055] As an example, you can first try to use CPU incomplete decoding to extract frames. After a period of time, such as completing 5 frame extractions, the system will decide whether to use GPU incomplete decoding to extract frames. p <0.5AND U c <0.2) or (D p <0.4AND U c <0.4) or (D p <0.2AND U c <0.6) or (D p <0.1AND U c <0.8) CPU decoding is still used, otherwise the current CPU decoding context is disabled and GPU incomplete decoding and frame extraction are enabled.
[0056] When the decoding ratio D p When the CPU usage Uc is low, the CPU decoding takes up a lot of computing resources. p >=0.5 will use GPU incomplete decoding to extract frames. p Low CPU usage U c When the CPU is too high, the stable operation of the system needs to be guaranteed, and the CPU cannot be used for decoding and frame extraction. c >=0.8 will also use GPU incomplete decoding and frame extraction.
[0057] In an embodiment of the present application, when both CPU and GPU resources exist in the system, in order to fully utilize the CPU / GPU computing resources while ensuring stable operation of the system, the method provided in the embodiment of the present application can realize automatic switching between CPU decoding frame extraction and GPU decoding frame extraction based on the decoding ratio in incomplete decoding frame extraction and CPU utilization, thereby achieving the effect of simultaneously utilizing the CPU and GPU for efficient decoding frame extraction.
[0058] The present application scheme is further described below in conjunction with specific application scenarios. Of course, the following application scenarios are only exemplary and can also be applied to other application scenarios in actual applications.
[0059] Figure 3 The figure is a flowchart of a video frame extraction method in a specific application example.
[0060] refer to Figure 3 As shown, the method may include:
[0061] In step S301, the frame extraction service is started, and an input video stream is prepared to be received, and frames of the video stream are extracted according to a fixed frame interval X.
[0062] In step S302, an input video stream is received and the current average frame rate is counted. When the first key frame is encountered, it is independently decoded and encoded into a JPEG picture and sent as a frame extraction picture, and the key frame position L is recorded. Initially, the current average frame rate can be set to infinity.
[0063] In step S303, the video frames are continuously received and buffered, and when the target frame to be extracted appears, the current target frame position is recorded as K.
[0064] In step S304, it is determined whether the condition |KL|<δ*F is satisfied, where K is the position of the current target frame, L is the position of the current key frame, F is the current average frame rate, and δ is an adjustment factor in the range of [0,1).
[0065] In step S305, if the conditions are met, the current key frame is independently decoded and encoded into a JPEG picture and sent as a frame extraction picture, the key frame position L is refreshed, and the cache is cleared. In other words, the neighbor key frame L is used to replace the target frame for output.
[0066] In step S306, if the condition is not met, the δ*F frames are buffered backwards.
[0067] In step S307, it is determined whether a key frame is encountered during the process of caching the δ*F frame.
[0068] In step S308, if a key frame is encountered, it is decoded independently as the current key frame and encoded into a JPEG picture and sent as a frame extraction picture, the key frame position L is refreshed, and the cache is cleared.
[0069] In step S309, if no key frame is encountered, the video frames before and including the target frame in the cache are decoded in sequence (while accumulating the number of decoded frames D f ), then encode the target frame into a JPEG image and send it out, and clear the cached video frame sequence before the target frame. During the caching process, each time a key frame is encountered, the current key frame position L is updated and the cache sequence is cleared.
[0070] The reason why the target frame can be replaced by the neighbor key frame is that: a) according to the basic knowledge of image coding, adjacent images are correlated; b) in the video intelligent analysis scenario, the main purpose is to sample and analyze abnormal situations in the video, and the frame extraction interval does not need to be completely accurate. When the adjustment factor δ is smaller and closer to the target frame, the system can preset or configure the adjustment factor to meet the requirements of different frame extraction accuracy.
[0071] For example, assuming that the frame rate F and the key frame interval are both 20, the frame extraction interval is 15, and the value of δ is 0.25, when the frame extraction target is the frame with the sequence number K=15, it does not meet the condition of |KL|<δ*F, that is, |15-0|<0.25*20 (the position L of the previous key frame is 0), and δ*F=5 frames are cached backward. It is found that the 20th frame is exactly the key frame, and the frame is used to replace the frame extraction target, encoded as the target picture and sent out, and the key frame position L=20 is updated. When the frame extraction target sequence number K=30 appears, it does not meet the condition of |KL|<δ*F, that is, |30-20|<0.25*20, and δ*F frames are cached backward without encountering a key frame. At this time, it is necessary to decode the frames with sequence numbers 21 to 30 in the cache in sequence (and accumulate the number of decoded frames), encode the frame with sequence number 30 as the target picture, and clear the frames 21 to 30 in the cache. By analogy, the target frames with sequence numbers 45, 60, and 75 will be replaced by key frames with sequence numbers 40, 60, and 80, and the target frame with sequence number 90 will not be replaced by a key frame. After the frames with sequence numbers 81 to 90 are decoded in sequence (and the number of decoded frames is accumulated), the frame with sequence number 90 will be encoded as the target picture and sent out.
[0072] In particular, when the frame rate F and the key frame interval are integer multiples of the frame extraction interval, the incomplete decoding frame extraction method in the present application solution will automatically degenerate into decoding and extracting frames for only the key frames, which can greatly improve the frame extraction efficiency of the system. In addition, the incomplete decoding frame extraction method is also applicable to the scene of extracting video frames according to time intervals.
[0073] The embodiment of the present application also provides a method for automatically switching between CPU and GPU incomplete decoding frame extraction. When there are CPU and GPU resources in the system, it is necessary to make full use of the system resources. According to the number of decoded frames D in the incomplete frame extraction, f The total number of frames processed T f Scale D p =D f / T f And the current CPU usage U c Determines whether GPU incomplete decoding frame extraction is enabled.
[0074] As an example, you can first try to use CPU incomplete decoding to extract frames. After a period of time, such as completing 5 frame extractions, the system will decide whether to use GPU incomplete decoding to extract frames. p<0.5AND U c <0.2) or (D p <0.4AND U c <0.4) or (D p <0.2AND U c <0.6) or (D p <0.1AND U c <0.8) CPU decoding is still used, otherwise the current CPU decoding context is disabled and GPU incomplete decoding and frame extraction are enabled.
[0075] When the decoding ratio D p When the CPU usage Uc is low, the CPU decoding takes up a lot of computing resources. p >=0.5 will use GPU incomplete decoding to extract frames. p Low CPU usage U c When the CPU is too high, the stable operation of the system needs to be guaranteed, and the CPU cannot be used for decoding and frame extraction. c >=0.8 will also use GPU incomplete decoding and frame extraction.
[0076] In an embodiment of the present application, when both CPU and GPU resources exist in the system, in order to fully utilize the CPU / GPU computing resources while ensuring stable operation of the system, the method provided in the embodiment of the present application can realize automatic switching between CPU decoding frame extraction and GPU decoding frame extraction based on the decoding ratio in incomplete decoding frame extraction and CPU utilization, thereby achieving the effect of simultaneously utilizing the CPU and GPU for efficient decoding frame extraction.
[0077] See also Figure 4 As shown, the embodiment of the present application also provides a video frame extraction device. Figure 4 It is a structural schematic diagram of a video frame extraction device provided in one embodiment of the present application.
[0078] The device may include:
[0079] The frame extraction module 401 is used to extract frames from the input video stream according to a preset interval;
[0080] The recording module 402 is used to record the latest encountered key frame as the current key frame and the latest extracted target frame as the current target frame during the frame extraction process of the frame extraction module;
[0081] The replacement output module 403 is used to determine whether the position of the current target frame, the position of the current key frame and the current average frame rate meet the specified conditions; if the specified conditions are met, the current key frame is decoded and outputted instead of the current target frame; if the specified conditions are not met, it is determined whether a key frame is encountered in the video frames within a specified number after the current target frame. If a key frame is encountered, the encountered key frame is outputted instead of the current target frame; if no key frame is encountered, the current target frame and the video frames between the current target frame and the current key frame are decoded in sequence, and the current target frame is outputted based on the decoding.
[0082] Optionally, in some embodiments, the specified conditions include:
[0083] |KL|<δ*F, where K is the position of the current target frame, L is the position of the current key frame, F is the current average frame rate, and δ is the adjustment factor, with a value range of [0,1);
[0084] Specified quantities include: δ*F.
[0085] Optionally, in some embodiments, the preset interval includes:
[0086] Video frame interval or time interval.
[0087] Optionally, in some embodiments, the current average frame rate includes:
[0088] The average frame rate during the specified time period before the current keyframe.
[0089] Optionally, in some embodiments, the device may further include:
[0090] Switching module, used to accumulate the total number of processed frames T f , and the cumulative number of decoded frames D when the current target frame and the video frames between the current target frame and the current key frame are decoded in sequence f ; Calculate the current T with the specified period f and D f The ratio D p , and obtain the current CPU usage U c According to D p and U c , switch between using CPU decoding and GPU decoding.
[0091] Optionally, in some embodiments, the switching module is configured to switch the p and U c , when switching between using CPU decoding and GPU decoding, it is specifically used for:
[0092] When D p is less than the first preset value and Uc When it is less than a second preset value, CPU decoding and frame extraction are disabled and GPU decoding and frame extraction are enabled.
[0093] The method provided in the embodiment of the present application is a device for incomplete decoding and frame extraction. It does not need to perform complex decoding output on each extracted target frame. Instead, in some cases, neighbor key frames are used to directly replace the target frame decoding output. This greatly improves the efficiency of frame extraction decoding while ensuring the approximate accuracy of the extracted frame image. It also does not require other hardware assistance and has wide applicability.
[0094] In addition, when both CPU and GPU resources exist in the system, in order to make full use of CPU / GPU computing resources while ensuring stable operation of the system, the device provided in the embodiment of the present application can realize automatic switching between CPU decoding frame extraction and GPU decoding frame extraction based on the decoding ratio in incomplete decoding frame extraction and CPU utilization, thereby achieving the effect of efficient decoding frame extraction using both CPU and GPU at the same time.
[0095] Figure 5 A schematic diagram of the hardware structure of a terminal device involved in an embodiment of the present application is shown.
[0096] The terminal device may include a processor 501 and a memory 502 storing computer program instructions.
[0097] Specifically, the processor 501 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0098] The memory 502 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 502 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 502 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 502 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 502 is a non-volatile solid-state memory.
[0099] In certain embodiments, the memory 502 may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0100] The processor 501 implements any one of the video frame extraction methods in the above embodiments by reading and executing computer program instructions stored in the memory 502 .
[0101] In one example, the terminal device may further include a communication interface 503 and a bus 510. Figure 5 As shown, the processor 501, the memory 502, and the communication interface 503 are connected via a bus 510 and communicate with each other.
[0102] The communication interface 503 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0103] Bus 510 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-end bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 510 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0104] In addition, in combination with the video frame extraction method in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any video frame extraction in the above embodiment is implemented.
[0105] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0106] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0107] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0108] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0109] The above are only specific implementation methods of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A video frame extraction method, characterized in that: The method comprises: Extract frames from the input video stream at preset intervals, and during the frame extraction process, record the most recently encountered key frame as the current key frame, and record the most recently extracted target frame as the current target frame; Determine whether the position of the current target frame, the position of the current key frame and the current average frame rate meet the specified conditions; If the specified condition is met, the current key frame is decoded and outputted instead of the current target frame; If the specified condition is not met, determine whether a key frame is encountered in the specified number of video frames after the current target frame. If a key frame is encountered, the encountered key frame will be output instead of the current target frame. If no key frame is encountered, the current target frame and the video frames between the current target frame and the current key frame will be decoded in sequence, and the current target frame will be output based on the decoding.
2. The method according to claim 1, characterized in that: The specified conditions include: |KL|<δ*F, where K is the position of the current target frame, L is the position of the current key frame, F is the current average frame rate, and δ is an adjustment factor, and its value range is [0,1); The specified quantity includes: δ*F.
3. The method according to claim 1, characterized in that The preset interval includes: Video frame interval or time interval.
4. The method according to claim 1, characterized in that: The current average frame rate includes: The average frame rate during the specified time period before the current keyframe.
5. The method according to claim 1, characterized in that The method further comprises: The total number of frames processed is T f , and the cumulative number of decoded frames D when the current target frame and the video frames between the current target frame and the current key frame are decoded in sequence f ; Calculate the current T with the specified period f and D f The ratio D p , and obtain the current CPU usage U c ; According to D p and U c , switch between using CPU decoding and GPU decoding.
6. The method according to claim 5, characterized in that According to D p and U c , switch between using CPU decoding and GPU decoding, including: When D p is less than the first preset value and U c When it is less than a second preset value, CPU decoding and frame extraction are disabled and GPU decoding and frame extraction are enabled.
7. A video frame extraction device, characterized in that: The device comprises: A frame extraction module is used to extract frames from the input video stream according to a preset interval; A recording module, used for recording the most recently encountered key frame as the current key frame and the most recently extracted target frame as the current target frame during the frame extraction process of the frame extraction module; The replacement output module is used to determine whether the position of the current target frame, the position of the current key frame and the current average frame rate meet the specified conditions; if the specified conditions are met, the current key frame is decoded and outputted instead of the current target frame; if the specified conditions are not met, it is determined whether a key frame is encountered in the video frames within a specified number after the current target frame. If a key frame is encountered, the encountered key frame is outputted instead of the current target frame; if no key frame is encountered, the current target frame and the video frames between the current target frame and the current key frame are decoded in sequence, and the current target frame is outputted based on the decoding.
8. The device according to claim 7, characterized in that: The specified conditions include: |KL|<δ*F, where K is the position of the current target frame, L is the position of the current key frame, F is the current average frame rate, and δ is an adjustment factor, and its value range is [0,1); The specified quantity includes: δ*F.
9. The device according to claim 7, characterized in that The preset interval includes: Video frame interval or time interval.
10. The device according to claim 7, characterized in that The current average frame rate includes: The average frame rate during the specified time period before the current keyframe.
11. The device according to claim 7, characterized in that The device also includes: Switching module, used to accumulate the total number of processed frames T f , and the cumulative number of decoded frames D when the current target frame and the video frames between the current target frame and the current key frame are decoded in sequence f ; Calculate the current T with the specified period f and D f The ratio D p , and obtain the current CPU usage U c According to D p and U c , switch between using CPU decoding and GPU decoding.
12. The device according to claim 11, characterized in that The switching module is based on D p and U c , when switching between using CPU decoding and GPU decoding, it is specifically used for: When D p is less than the first preset value and U c When it is less than a second preset value, CPU decoding and frame extraction are disabled and GPU decoding and frame extraction are enabled.
13. A terminal device, characterized in that: The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the video frame extraction method according to any one of claims 1 to 6 is implemented.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the video frame extraction method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Video stream detection method and device, equipment, storage medium and program product
CN119893124A
Video stream detection method, device, equipment, storage medium and program product
CN119893124B
Video processing method, device, system and equipment and storage medium
CN120416541A
