Disclosure of Invention
The embodiment of the invention aims to provide a method for generating a video recording, so as to prevent the data volume of the video recording from being overlarge while recording a segment of interest. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a method for generating a video recording, where the method includes:
writing video data generated by video recording of the content displayed by the display terminal into a target storage area;
determining whether a preset deleting condition is met or not in the video recording process, and deleting the non-interested data in the target storage area under the condition that the preset deleting condition is met; the non-interested data is the appointed part data written first in the video data stored in the target storage area at present;
and when a screen recording ending instruction is received, generating a screen recording video based on the video data remained in the target storage area.
Optionally, the preset deletion condition is: and the data size of the video data currently stored in the target storage area reaches a first preset threshold value.
Optionally, the deleting the data not of interest in the target storage area includes:
determining data which is generated first in the video data currently stored in the target storage area and has the data size of a second preset threshold value as non-interested data;
deleting the non-interesting data in the target storage area.
Optionally, the determining whether the preset deletion condition is met includes:
when reaching the detection moment of periodic detection, detecting whether a preset deletion condition is met;
after the deleting the non-interesting data in the target storage area, the method further comprises:
and when the detection time of the next periodic detection is reached, returning to the step of executing whether the detection meets the preset deletion condition or not until a screen recording ending instruction is received.
Optionally, the deleting the non-interesting data in the target storage area includes:
intercepting data with the data size of a second preset threshold value from the first bit of video data currently stored in the target storage area;
delete the intercepted data.
Optionally, the determining whether the preset deletion condition is met includes:
determining whether a periodical deletion time is reached, and if so, determining that a preset deletion condition is met;
after the deleting the non-interesting data in the target storage area, the method further comprises:
and determining whether the next periodic deletion time is reached, and if so, returning to the step of executing the deletion processing of the non-interested data in the target storage area until a screen recording ending instruction is received.
In a second aspect, an embodiment of the present invention provides a device for generating a video recording, where the device includes:
the writing module is used for writing video data generated by video recording of the content displayed by the display terminal into the target storage area;
the deleting module is used for determining whether a preset deleting condition is met or not in the video recording process, and deleting the non-interested data in the target storage area under the condition that the preset deleting condition is met; the non-interested data is the appointed part data written first in the video data stored in the target storage area at present;
and the generating module is used for generating the video recording based on the video data remained in the target storage area when receiving the video recording ending instruction.
Optionally, the preset deletion condition is: and the data size of the video data currently stored in the target storage area reaches a first preset threshold value.
Optionally, the deleting module performs deleting processing on the data not interested in the target storage area, including:
determining data which is generated first in the video data currently stored in the target storage area and has the data size of a second preset threshold value as non-interested data;
deleting the non-interesting data in the target storage area.
Optionally, the deletion module determines whether a preset deletion condition is satisfied, including:
when reaching the detection moment of periodic detection, detecting whether a preset deletion condition is met;
the deleting module is further configured to return to executing the step of detecting whether the detection meets a preset deleting condition when a detection time of the next periodic detection is reached after the deleting process is performed on the non-interested data in the target storage area, until a screen recording end instruction is received.
Optionally, the deleting module deletes the non-interesting data in the target storage area, including:
intercepting data with the data size of a second preset threshold value from the first bit of video data currently stored in the target storage area;
delete the intercepted data.
Optionally, the deletion module determines whether a preset deletion condition is satisfied, including:
determining whether a periodical deletion time is reached, and if so, determining that a preset deletion condition is met;
the deletion module is further configured to, after the deletion process is performed on the data not of interest in the target storage area,
and determining whether the next periodic deletion time is reached, and if so, returning to the step of executing the deletion processing of the non-interested data in the target storage area until a screen recording ending instruction is received.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the steps of the method for generating the video recording when executing the program stored in the memory.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium, in which a computer program is stored, where the computer program when executed by a processor implements the steps of the method for generating a video recording as described above.
The embodiment of the invention also provides a computer program product containing instructions, which when run on a computer, cause the computer to execute the method for generating the video recording according to any one of the above.
The embodiment of the invention has the beneficial effects that:
according to the method for generating the video recording, disclosed by the embodiment of the invention, video recording is carried out on the content displayed by the display terminal, and generated video data is written into the target storage area; in the video recording process, determining whether a preset deleting condition is met, and deleting non-interested data in a target storage area under the condition that the preset deleting condition is met; the non-interested data is the appointed part data written first in the video data stored in the target storage area at present; and when receiving a screen recording ending instruction, generating a screen recording video based on the video data remained in the target storage area. Therefore, in the scheme, when the preset deleting condition is met in the video recording process, part of video data is deleted, so that the overlarge data volume generated by screen recording can be avoided; when the screen recording ending instruction is received, the fact that the interested fragment is recorded is described, and the part of video data written in the target storage area first is deleted, so that the interested fragment can be reserved. Therefore, through the scheme, the data volume of the video recording can be prevented from being too large while the interested fragment is recorded.
Of course, it is not necessary for any one product or method of practicing the invention to achieve all of the advantages set forth above at the same time.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, those of ordinary skill in the art will be able to devise all other embodiments that are obtained based on this application and are within the scope of the present invention.
The common scenes applied to the current screen recording, such as scenes of net lesson recording, office meeting recording, software testing process recording and the like, generally the duration of the obtained screen recording video can be basically determined, and the size is controllable. In some scenarios, there may be a case where a user wants to record a segment of interest in a content displayed by the display terminal, but cannot determine a specific time when the segment of interest appears, for example, when a tester or a customer service personnel uses a certain software, a test person finds some recurrent problems and needs to record a recurrent process of the recurrent problems, but does not determine a specific time when the recurrent problems may be recurrent, which may result in that a recording duration cannot be determined, and as the recording duration increases, a data amount of a video may be too large, or even exceeds an available storage space.
In order to solve the above problems and avoid overlarge data size of a video recording while recording a segment of interest, embodiments of the present invention provide a method, an apparatus, and an electronic device for generating a video recording. The method can be applied to electronic equipment with picture display and data processing capability, such as a smart phone, a computer and the like, or can be applied to video acquisition equipment for recording pictures displayed by a display terminal. In addition, the method for generating the video recording can be realized by software, hardware or a combination of the software and the hardware.
The following first describes a method for generating a video recording provided by the embodiment of the present invention.
The method for generating the video recording provided by the embodiment of the invention comprises the following steps:
writing video data generated by video recording of the content displayed by the display terminal into a target storage area;
in the video recording process, determining whether a preset deleting condition is met, and deleting non-interested data in a target storage area under the condition that the preset deleting condition is met; the non-interested data is the appointed part data written first in the video data stored in the target storage area at present;
and when receiving a screen recording ending instruction, generating a screen recording video based on the video data remained in the target storage area.
In the embodiment, in the video recording process, when a preset deleting condition is met, part of video data is deleted, so that the overlarge data volume generated by recording can be avoided; when the screen recording ending instruction is received, the fact that the interested fragment is recorded is described, and the part of video data written in the target storage area first is deleted, so that the interested fragment can be reserved. Therefore, through the scheme, the data volume of the video recording can be prevented from being too large while the interested fragment is recorded.
The method for generating the video recording provided by the embodiment of the invention is described below with reference to the accompanying drawings.
As shown in fig. 1, the method for generating a video recording provided by the embodiment of the present invention may include the following steps:
s101, writing video data generated by video recording of the content displayed by the display terminal into a target storage area;
in this step, video recording can be started on the content displayed by the display terminal after receiving a screen recording start instruction, and video data is generated, where the screen recording start instruction can be sent by triggering an appointed key of the display terminal, and the key can be a physical key or a virtual key in a man-machine interaction interface. For example, in the case where the method for generating a video on a screen provided by the embodiment of the present invention is applied to a smart phone, the instruction for starting the screen on the screen may be issued by triggering a specific physical key of the smart phone, or may also be issued by triggering a specific virtual key in a man-machine interaction interface displayed on a display screen of the smart phone in a touch manner, which is not limited to this.
The target storage area may be a storage area in any storage medium, which may be an internal storage space in a smart phone, a computer, or the like, or an external storage medium, which may be a RAM (Random Access Memory ), a ROM (Read Only Memory), or the like. After starting video recording of the content displayed by the display terminal, the generated video data may be continuously written in the target storage area in the form of byte arrays. In addition, before the video recording starts, parameters such as video quality, resolution and the like can be set, or a compression algorithm such as h.264 (a video coding mode) and the like can be set, and the data size of the generated video data can be further controlled. And hardware acceleration functions, such as GPU (graphics processing unit, graphics processor) acceleration, may also be utilized during video recording to improve video coding efficiency.
S102, determining whether a preset deleting condition is met in the video recording process, and deleting non-interested data in a target storage area under the condition that the preset deleting condition is met; the non-interested data is the appointed part data written first in the video data stored in the target storage area at present;
in one implementation, the preset deletion condition may be: the size of the data volume of the video data currently stored in the target storage area reaches a first preset threshold. In this case, whether the data size of the video data currently stored in the target storage area reaches the first preset threshold value can be detected in real time, and when the data size of the video data currently stored in the target storage area reaches the first preset threshold value, deletion processing is performed on the non-interested data. The non-interested data is the first written specified part of the video data stored in the target storage area, for example, the first data with the data size of the second preset threshold value can be generated in the video data stored in the target storage area. Further, the deleting the non-interested data in the target storage area may include: determining that data which is generated first in the video data currently stored in the target storage area and has the data size of a second preset threshold value is non-interested data; deleting the non-interesting data in the target storage area, namely deleting all the determined non-interesting data. Of course, some data in the non-interesting data may be deleted, for example, randomly deleting a data segment in which the data amount in the non-interesting data is the third preset threshold.
The data size of the video data currently stored in the target storage area reaches a first preset threshold value to serve as a preset deleting condition, so that the data size generated by video recording can be accurately controlled, and the overlarge video data generated by screen recording can be more effectively avoided.
In another embodiment of the present invention, a method for deleting data according to a predetermined time is also provided, where the predetermined time may be preset, for example, 1 minute, 3 minutes, or the like after the start of video recording. The predetermined time may be one or a plurality of times. If the number of the set times is plural, timing can be started while video recording is started, when the first set time is reached, the operation of deleting the non-interested data in the target storage area is executed for the first time, then the operation of deleting the non-interested data in the target storage area is executed again after the next set time is reached, and so on until the video recording is finished. If the video recording is not finished after the last preset time is reached, the deleting operation can be not executed any more, or the deleting operation can be executed according to the preset time interval, namely, after the last preset time is reached, the deleting operation is executed once every preset time interval, and the video recording is finished.
In another implementation manner, the process of determining whether the preset deletion condition is met may include: determining whether a periodical deletion time is reached, and if so, determining that a preset deletion condition is met; determining that a preset deletion condition is met, deleting the non-interested data in the target storage area, determining whether the next periodic deletion moment is reached or not again after the deletion, and if so, returning to the step of executing the deletion of the non-interested data in the target storage area until a screen recording end instruction is received. In this embodiment, the periodic deletion time may be set in advance, and for example, a time that is reached every one minute after the start time of video recording may be set as the periodic deletion time. In the implementation process, timing can be started at the starting time of video recording, and when the timing time reaches the periodical deletion time, deletion processing is performed on the non-interested data in the target storage area. In the implementation manner, the deleting process is performed on the non-interested data in the target storage area every time the periodical deleting time is reached, the step of detecting the size of the data amount can be omitted regardless of the size of the data amount, and therefore computing resources are saved.
In order to realize deleting the first data with the data size of the second preset threshold value in the currently stored video data, for example, the data with the data size of the second preset threshold value can be intercepted from the first bit of the currently stored video data in the target storage area, and then the intercepted data is deleted. Specifically, this can be achieved using a string function. By intercepting data from the first digit of the currently stored video data and deleting the intercepted data, the first generated video data can be deleted efficiently and simply.
Alternatively, the above-mentioned non-interesting data may be data that is generated first in the video data currently stored in the target storage area and has a proportion of the data amount to the total data amount currently stored that is a preset proportion, for example, the preset proportion may be 50%.
In another implementation manner, the preset deletion condition may be: the video time of the video represented by the video data currently stored in the target storage area reaches a first preset time length. In this case, the timing may be performed at the video recording start time, and when the timing duration reaches the first preset duration, the preset deletion condition is considered to be satisfied, and then deletion processing is performed on the specified portion of the video data currently stored in the target storage area, for example, the video data, which is written first and is characterized by the video and has the video duration of the second preset duration, may be deleted, then the timing duration is subtracted by the second preset duration, and timing is continued on the basis until the first preset duration is reached again, and the process of deletion processing is re-performed.
It can be understood that, when the recording is performed on the interested fragment, the recording is often started at an earlier time, and the recording is finished after the interested fragment is recorded, so that the video data of the recorded interested fragment is often the data generated later, therefore, the designated part data written first in the step is regarded as the non-interested data, and the deletion processing is performed on the designated part data, so that the deletion of the video data of the interested fragment can be avoided while the data amount of the video data is reduced.
S103, when a screen recording end instruction is received, generating a screen recording video based on the video data remained in the target storage area.
The method for generating the recording end instruction may be similar to the method for generating the recording start instruction, and will not be described herein. And when a screen recording ending instruction is received, generating a screen recording video based on the video data currently remained in the target storage area. It can be understood that in this step, if the video data stored in the target storage area does not meet the preset deletion condition all the time in the whole video recording process, it indicates that the generated video data is not deleted, and the recorded video is generated based on all the generated video data generated by video recording the content displayed by the display terminal. If the generated video data is subjected to deleting processing in the video recording process, the recorded video is generated based on the video data subjected to deleting processing.
The generating the video may include directly using video data remaining in the target storage area as a video file of the video; or, the video data remained in the target storage area can be compressed, converted in format and the like to obtain the video recording. Therefore, through the scheme, after the recording is finished, the generated video file only contains a section of video data which is interested by the user before the recording is finished, so that the occupation of the storage space can be greatly reduced, the resource utilization rate is improved, the intelligence of the screen recording function is improved, and the user experience is further improved.
In the embodiment, in the video recording process, when a preset deleting condition is met, part of video data is deleted, so that the overlarge data volume generated by recording can be avoided; when the screen recording ending instruction is received, the fact that the interested fragment is recorded is described, and the part of video data written in the target storage area first is deleted, so that the interested fragment can be reserved. Therefore, through the scheme, the data volume of the video recording can be prevented from being too large while the interested fragment is recorded.
Optionally, in another embodiment of the present invention, the method for generating a video on a screen may be performed in a periodic detection manner, that is, video data generated by video recording of content displayed on a display terminal is written into a target storage area, and in the process of video recording, when a detection time of the periodic detection is reached, whether a preset deletion condition is met is detected, and when the preset deletion condition is met, deletion processing is performed on non-interested data in the target storage area, and when a detection time of the next periodic detection is reached, a step of executing whether the detection meets the preset deletion condition is returned until a screen recording end instruction is received.
On the basis of the above embodiment, as shown in fig. 2, the embodiment of the present invention further provides a method for generating a video recording, including:
s201, writing video data generated by video recording of the content displayed by the display terminal into a target storage area;
this step is similar to the step S101 described above, and will not be described again here.
S202, whether a screen recording ending instruction is received before the detection moment of periodic detection is reached;
if yes, go to step S206. If not, go to step S203.
S203, detecting whether a preset deleting condition is met or not when a detection moment of periodic detection is reached in the video recording process;
in this step, the periodic detection is performed at intervals of a predetermined time, for example, at intervals of ten seconds. In the process of detecting whether the preset deleting condition is met, detecting that the data size of the video data currently stored in the target storage area reaches a first preset threshold value;
if yes, go to step S204. If not, go to step S205.
S204, deleting the non-interested data in the target storage area;
the step can be specifically referred to the step S102, and will not be described herein.
S205, whether a screen recording ending instruction is received before the detection time of the next periodicity detection is reached;
if yes, go to step S206. If not, returning to step S203, detecting whether the preset deletion condition is satisfied.
If it is detected that the preset deletion condition is not satisfied during a certain detection, the detection is not performed this time, the next detection time is waited, and when the detection time of the next periodic detection is reached, whether the preset deletion condition is satisfied is detected again, until a screen recording end instruction is received, and step S206 is executed.
S206, when a screen recording end instruction is received, generating a screen recording video based on the video data remained in the target storage area.
The step can be specifically referred to the above step S103, and will not be described herein.
In this embodiment, the data volume of the video recording can be prevented from being too large while the interested fragment is recorded. Furthermore, deletion processing is performed on the non-interested data in a periodic detection mode, an implementation basis is provided for the method for generating the video recording provided by the embodiment of the invention, and compared with real-time detection, the periodic detection mode of the embodiment can reduce the occupation of computing resources.
For convenience of understanding, the method for generating the video on the screen provided by the embodiment of the invention is described in the following with reference to a specific application scenario.
In the case that the method for generating the video on the screen provided by the embodiment of the invention is applied to the process of recording the recurrence of the recurrence problem, the method can comprise the following steps:
the first step: the first preset threshold and the second preset threshold are set, for example, the first preset threshold may be 40M and the second preset threshold may be 20M.
And a second step of: and starting screen recording, and recording the starting time.
And a third step of: the size of the data amount of the generated video data is compared with that of 40M every 10 seconds in the screen recording process.
Fourth step: and if the data size of the currently generated video data is greater than or equal to 40M, intercepting the first generated 20M data in the current video data, deleting, retaining the rest video data, and continuing recording the video data generated after the recording.
Fifth step: when the data size of the video data generated at present is larger than or equal to 40M in the next comparison, the 20M data generated at first in the current video data is intercepted for deletion, and the remaining video data is reserved for the video data generated after the continuous recording.
Sixth step: repeating the third to fifth steps until the problem of the occurrence is repeated, clicking to finish the screen recording, and reserving the final video data to generate a video file.
In the embodiment, in the video recording process, when a preset deleting condition is met, part of video data is deleted, so that the overlarge data volume generated by recording can be avoided; when the screen recording ending instruction is received, the fact that the interested fragment is recorded is described, and the part of video data written in the target storage area first is deleted, so that the interested fragment can be reserved. Therefore, through the scheme, the data volume of the video recording can be prevented from being too large while the interested fragment is recorded.
The embodiment of the invention also provides a device for generating the video recording, as shown in fig. 3, the device comprises:
a writing module 301, configured to write video data generated by video recording of content displayed by the display terminal into the target storage area;
the deleting module 302 is configured to determine whether a preset deleting condition is satisfied during the video recording process, and delete non-interested data in the target storage area if the preset deleting condition is satisfied; the non-interested data is the appointed part data written first in the video data stored in the target storage area at present;
and the generating module 303 is configured to generate a video recording based on the video data remaining in the target storage area when receiving a recording end instruction.
Optionally, the preset deletion condition is: and the data size of the video data currently stored in the target storage area reaches a first preset threshold value.
Optionally, the deleting module performs deleting processing on the data not interested in the target storage area, including:
determining data which is generated first in the video data currently stored in the target storage area and has the data size of a second preset threshold value as non-interested data;
deleting the non-interesting data in the target storage area.
Optionally, the deletion module determines whether a preset deletion condition is satisfied, including:
when reaching the detection moment of periodic detection, detecting whether a preset deletion condition is met;
the deleting module is further configured to return to executing the step of detecting whether the detection meets a preset deleting condition when a detection time of the next periodic detection is reached after the deleting process is performed on the non-interested data in the target storage area, until a screen recording end instruction is received.
Optionally, the deleting module, deleting the non-interesting data in the target storage area includes:
intercepting data with the data size of a second preset threshold value from the first bit of video data currently stored in the target storage area;
delete the intercepted data.
Optionally, the deletion module determines whether a preset deletion condition is satisfied, including:
determining whether a periodical deletion time is reached, and if so, determining that a preset deletion condition is met;
the deletion module is further configured to, after the deletion process is performed on the data not of interest in the target storage area,
and determining whether the next periodic deletion time is reached, and if so, returning to the step of executing the deletion processing of the non-interested data in the target storage area until a screen recording ending instruction is received.
The embodiment of the invention also provides an electronic device, as shown in fig. 4, which comprises a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402 and the memory 403 complete communication with each other through the communication bus 404,
a memory 403 for storing a computer program;
the processor 401 is configured to implement the steps of the method for generating a video recording as described above when executing the program stored in the memory 403.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, there is further provided a computer readable storage medium having a computer program stored therein, the computer program when executed by a processor implementing the steps of any one of the methods for generating a video recording described above.
In yet another embodiment of the present invention, a computer program product containing instructions that, when run on a computer, cause the computer to perform the method of generating a video recording of any of the above embodiments is also provided.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.