Summary of the invention
Embodiment of the present invention technical problem to be solved is, provides a kind of method for processing video frequency, device and client.Cpu resource consumption in video processing procedure can be solved in prior art large and take the large problem of memory space.
In order to solve the problems of the technologies described above, embodiments provide a kind of method for processing video frequency, comprising:
The lock notification that receiver, video harvester sends; Described lock notification is for representing that described video acquisition device completes the lock operation to the video image generated;
Judge whether video encoder is in idle condition, if yes, described video image is converted to the copy of preset format;
After format conversion operation completes, send unlock notification to described video acquisition device, described unlock notification is used to indicate the locking of described video acquisition device releasing to described video image;
The copy of described preset format is sent to described video encoder, to make described video encoder, compressed encoding process is carried out to the copy of described preset format.
Accordingly, embodiments provide a kind of video process apparatus, comprising:
Receiver module, for the lock notification that receiver, video harvester sends; Described lock notification is for representing that described video acquisition device completes the lock operation to the video image generated;
Modular converter, for judging whether video encoder is in idle condition, if yes, generating the copy of described video image, and the format conversion of described copy is become preset format;
Unlock notification module, for after format conversion operation completes, sends unlock notification to described video acquisition device, and described unlock notification is used to indicate the locking of described video acquisition device releasing to described video image;
Coding indicating module, for the copy of described preset format is sent to described video encoder, carries out compressed encoding process to make described video encoder to the copy of described preset format.
Accordingly, embodiments provide a kind of client, comprising:
Video acquisition device, video encoder and video process apparatus;
Described video acquisition device generating video image, locks described video image, and after completing lock operation, sends lock notification to described video process apparatus;
The lock notification that described video process apparatus receiver, video harvester sends; Described lock notification is for representing that described video acquisition device completes the lock operation to the video image generated;
Described video process apparatus judges whether video encoder is in idle condition, if yes, described video image is converted to the copy of preset format;
After format conversion operation completes, described video process apparatus sends unlock notification to described video acquisition device, and described unlock notification is used to indicate the locking of described video acquisition device releasing to described video image;
After described video acquisition device receives described unlock notification, remove the locking to described video image;
The copy of described preset format is sent to described video encoder by described video process apparatus;
Described video encoder carries out compressed encoding process to the copy of described preset format.
Implement the embodiment of the present invention, there is following beneficial effect:
Receive the lock notification of video acquisition device, when judging that video encoder is in idle condition, directly follow-up format conversion processing is carried out to the video image of the lock-out state that video acquisition device generates, avoid carrying out copy operation to unpressed video image, effectively can decrease the consumption of CPU and decrease taking of memory space.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
In order to better understand a kind of method for processing video frequency, device and client disclosed in the embodiment of the present invention, first the Living Network framework that the embodiment of the present invention is suitable for is described below.Refer to Fig. 1, Fig. 1 is a kind of Living Network framework schematic diagram disclosed in the embodiment of the present invention.As shown in Figure 1, this Living Network framework can comprise service equipment and multiple client, and wherein, service equipment is also by title background server, component server etc., and service equipment can be communicated to connect by the Internet and multiple client.
In the Living Network framework shown in Fig. 1, the part client in multiple client can as main broadcaster's client, and all the other clients can as spectator client.In the embodiment of the present invention, channel is exactly briefly a kind of Virtual Space (or virtual room) that service equipment creates, the spectator client being positioned at this Virtual Space not only can watch the live content of main broadcaster's client, can also and main broadcaster's client carry out the mutual of voice or word.Main broadcaster's client not only has access to all the other spectator client in its channel of access, kicks out of control, also has live initiative.In the embodiment of the present invention, main broadcaster's client, spectator client can realize comprising the several functions such as set group chat, net cast, channel K song, game on line, online video display.In the Living Network framework shown in Fig. 1, main broadcaster's client, spectator client may operate in and include but not limited on the subscriber equipment such as mobile phone, removable computer, panel computer, personal digital assistant (Personal Digital Assistant, PDA), media player, intelligent television, intelligent watch, intelligent glasses, Intelligent bracelet.
Below in conjunction with Fig. 1 and Fig. 2., a kind of method for processing video frequency that the embodiment of the present invention provides is described in detail.
See Fig. 1, be the schematic flow sheet of a kind of method for processing video frequency that first embodiment of the invention provides, in embodiments of the present invention, described method comprises:
The lock notification that S101, receiver, video harvester send; Described lock notification is for representing that described video acquisition device completes the lock operation to the video image generated.
Concrete, video acquisition device is for generating the video image of uncompressed, the video image generated comprises multiple frame of video, video acquisition device can utilize optical sensor to carry out external environment condition gathering the video image generated, such as, video acquisition device is camera, video tape recorder or camera etc.; Video acquisition device also can a kind of application software, such as film recording software, is carried out the video image of film recording generation by the appointed area of the user interface to subscriber equipment.Video acquisition device collection after generating the video image of uncompressed, the video image collected is stored in the buffer memory of video acquisition device, and the video image in buffer memory is conducted the locking operations, lock operation refers to that video process apparatus has the exclusive operating right to video image, entity (such as device, program and thread) except video process apparatus is not to the operating right of video image, and the video image be simultaneously in the lock state in buffer memory maps directly to the buffer memory of video process apparatus.After video acquisition device completes lock operation to video image, lock notification is sent to video process apparatus, video process apparatus receives lock notification can determine that video acquisition device completes the lock operation to video image, and video process apparatus can utilize the video image of locking to carry out follow-up process.
S102, judge whether video encoder is in idle condition, if yes, described video image is converted to the copy of preset format.
Concrete, video encoder is used for carrying out compressed encoding to video image, removes the data message of video image, to reduce the file size of video image.Video process apparatus judges whether video encoder is in idle condition, by inquiry, the method judged can represent that the idle condition of video encoder or the status indicator position of busy condition judge, if video encoder is in idle condition, video process apparatus directly utilizes the video image be in the lock state in the buffer memory of video acquisition device to carry out format conversion, generates the copy of preset format.Like this, avoid the video image in the buffer memory of video acquisition device to copy in the buffering of video process apparatus, reduce the consumption of hardware resource during video image copy.
S103, after format conversion operation completes, send unlock notification to described video acquisition device, described unlock notification is used to indicate described video acquisition device and removes locking to described video image.
Concrete, after the format conversion of copy becomes the operation of preset format to complete by video process apparatus, notice video acquisition device removes the locking to video image, and after unlocking, video acquisition device can seize the operating right of video image.
S104, the copy of described preset format is sent to described video encoder, to make described video encoder, compressed encoding process is carried out to the copy of described preset format.
Concrete, video encoder carries out compressed encoding process to the copy of the video image after format conversion, to reduce information redundancy, Coding Compression Algorithm can be any one Coding Compression Algorithm of the prior art, such as, MPEG-4, JVT, H.264 with AVC etc., the present invention is not restricted.
Implement embodiments of the invention, receive the lock notification of video acquisition device, when judging that video encoder is in idle condition, directly follow-up format conversion processing is carried out to the video image of the lock-out state that video acquisition device generates, avoid carrying out copy operation to unpressed video image, effectively can decrease the consumption of CPU and decrease taking of memory space.
See Fig. 2, be the schematic flow sheet of a kind of method for processing video frequency that second embodiment of the invention provides, in embodiments of the present invention, described method comprises:
The lock notification that S201, detection video acquisition device send.
Concrete, video acquisition device is for generating the video image of uncompressed, the video image generated comprises multiple frame of video, video acquisition device can utilize optical sensor to carry out external environment condition gathering the video image generated, such as, video acquisition device is camera, video tape recorder or camera etc.; Video acquisition device also can a kind of application software, such as film recording software, is carried out the video image of film recording generation by the appointed area of the user interface to subscriber equipment.Video acquisition device collection after generating the video image of uncompressed, the video image collected is saved in buffer memory, and the video image in buffer memory is conducted the locking operations, lock operation refers to that video process apparatus has the exclusive operating right to video image, and the entity (such as device, program and thread) except video process apparatus is not to the operating right of video image.After video acquisition device completes lock operation to video image, lock notification is sent to video process apparatus, video process apparatus receives video acquisition device and receives lock notification and can determine that video acquisition device completes the lock operation to video image, and video process apparatus can utilize the video image of locking to carry out follow-up process.Wherein, the quantity of the frame of video comprised in video image can be determined according to the disposal ability of video encoder.Video process apparatus start detection thread, waits for the lock notification that video acquisition device sends.
Optionally, video acquisition device can be locked the video image collected by resource lock, resource lock is for characterizing a kind of mutual exclusion mechanism, before target resource being operated to (such as read operation or write operation), need to get resource lock corresponding to target resource, after operation requests object acquisition to the resource lock of target resource, other operation requests objects can not operate target resource again.After video acquisition device generating video resource, resource lock corresponding for video image can be set to seizure condition, and the identification presentation of video process apparatus is added in owner's list of this resource lock, represent that video process apparatus has the operating right exclusive to video image.
The lock notification that S202, receiver, video harvester send.
Concrete, after the detection thread of video process apparatus detects the lock notification that video acquisition device sends, receive this lock notification, lock notification is for representing that video acquisition device completes the lock operation of the video image to generation.Wherein, the address realm of video image is also comprised in lock notification, video process apparatus can according to the video image that address realm determination video acquisition device is in the lock state, so that video process apparatus utilizes the video image of locking to carry out follow-up process.
S203, judge whether video encoder is in idle condition.
Concrete, after video encoder starts, corresponding coding thread can be generated in an operating system, video process apparatus determination video encoder moves into coding thread in an operating system, and the status indicator of inquiry coding thread, it is idle condition or busy condition that status indicator is used for presentation code thread, judges whether video encoder is in idle condition according to the status indicator inquired.Such as, be idle condition with " 0 " presentation code thread, " 1 " identification code thread is busy condition.
Optionally, the state of the status poll interface polls video encoder that video process apparatus can be provided by video encoder, what represented by status poll interface polls that the status indicator of the state of video encoder determines video encoder is in idle condition or busy condition.If video encoder is in idle condition, perform S206, if be in busy condition, perform S204.
S204, send unlock notification to described video acquisition device.
Concrete, video process apparatus is when determining that video encoder is in busy condition, video encoder cannot carry out compressed encoding process to the video image of video acquisition device input, video process apparatus sends unlock notification to video acquisition device, to notify that video acquisition device removes the locking to video image, after unlocking, other entities can obtain the operating right to video image by the mode of competing.
Exemplary, in the scene of resource lock, video process apparatus sends unlock notification to video acquisition device, the state of the resource lock of video image is set to idle condition by video acquisition device, and the identify label of video acquisition device is deleted from owner's list, to remove the locking to video image.
S205, do not receive time of lock notification that described video acquisition device sends and be greater than preset duration.
Concrete, the time interval between the moment that video process apparatus calculating current time and last time receive the lock notification that video acquisition device sends, if calculate interval greater than preset duration, the notice to be entered such as continuation then shows that video acquisition device does not all receive lock notification in preset duration, if will cause the waste of hardware resource.
Exemplary, video process apparatus detected whether receive lock notification every 1 minute, and arranging preset duration is 5 minutes, when namely still not receiving the lock notification of video acquisition device transmission when the 6th sense cycle, performed S209.Be understandable that, the sense cycle of video process apparatus and preset duration can set according to actual needs, and the present invention does not limit concrete numerical value.
S206, described video image is converted to the copy of preset format.
Concrete, the video image be in the lock state is carried out format conversion operation by video process apparatus, generates the copy of preset format after format conversion, to meet the requirement of video encoder.
Exemplary, video encoder requires that the format condition of the image to be encoded of input is: resolution 1024*768, color space is RGB, the resolution of the video image that video acquisition device generates is 2048*1024, color space is YIQ, and the copy of the video image of generation is identical with the attribute information of video image, and video process apparatus is according to the corresponding relation of YIQ color space and RGB color space, be RGB color space by YIQ color space conversion, the corresponding relation of the two is:
Y=0.299R+0.587G+0.114B
I=0.596R-0.275G-0.321B
Q=0.212R-0.523G+0.311B
Meanwhile, video image carries out reducing process by video process apparatus, to meet the requirement of the resolution of video encoder.In an embodiment of the present invention, before carrying out compressed encoding to the copy of preset format, video process apparatus can also carry out other preliminary treatment to copy, such as, noise filtering, adds watermark or sample process etc.
S207, after format conversion operation completes, send unlock notification to described video acquisition device.
Concrete, after video process apparatus completes the process of format conversion,
Concrete, after video process apparatus completes the format conversion processing of copy, video process apparatus sends unlock notification to video acquisition device, to notify that video acquisition device removes the locking to video image, after unlocking, other entities can obtain the operating right to video image by the mode of competing.
Exemplary, in the scene of resource lock, video process apparatus sends unlock notification to video acquisition device, the state of the resource lock of video image is set to idle condition by video acquisition device, and the identify label of video acquisition device is deleted from owner's list, to remove the locking to video image.
S208, carry out compressed encoding process by the video image copy of described video encoder to described preset format.
Concrete, concrete, video encoder carries out compressed encoding process to the copy of the video image after format conversion, to reduce information redundancy, Coding Compression Algorithm can be any one Coding Compression Algorithm of the prior art, such as, MPEG-4, JVT, H.264 with AVC etc., the present invention is not restricted.
S209, exit mark and whether be set up.
Concrete, described in exit mark and be used to indicate Video processing processing unit and quit work, exiting mark can be undertaken arranging or being arranged by video acquisition device by user.Such as, after video acquisition device completes the acquisition operations to video source, follow-uply new video image can not generated, what video acquisition device arranged video process apparatus exits mark, when video process apparatus detects that exiting mark is set up, quit work and the hardware resource of release busy, hardware resource comprises memory source and cpu resource.Video process apparatus judges whether exit mark is set up, and if yes, performs S210, if NO, performs S201.
Again such as, when user does not need to carry out Video compression, perform and exit operation, what operating system arranged video process apparatus accordingly in a register exits mark, when video process apparatus detects that exiting mark is set up, quit work, the hardware resource of release busy.
The hardware resource of S210, release busy.
Implement embodiments of the invention, receive the lock notification of video acquisition device, when judging that video encoder is in idle condition, directly follow-up format conversion processing is carried out to the video image of the lock-out state that video acquisition device generates, avoid carrying out copy operation to unpressed video image, effectively can decrease the consumption of CPU and decrease taking of memory space.
See Fig. 3, be the structural representation of a kind of video process apparatus that first embodiment of the invention provides, in embodiments of the present invention, described video process apparatus comprises receiver module 10, modular converter 11, unlock notification module 12 and coding indicating module 13.
Receiver module 10, for the lock notification that receiver, video harvester sends; Described lock notification is for representing that described video acquisition device completes the lock operation to the video image generated.
Modular converter 11, for judging whether video encoder is in idle condition, if yes, converts the copy of preset format to by described video image.
Unlock notification module 12, for after format conversion operation completes, sends unlock notification to described video acquisition device, and described unlock notification is used to indicate the locking of described video acquisition device releasing to described video image.
Coding indicating module 13, for the copy of described preset format is sent to described video encoder, carries out compressed encoding process to make described video encoder to the copy of described preset format.
The embodiment of the present invention and embodiment of the method one are based on same design, and its technique effect brought is also identical, specifically please refer to the description of embodiment of the method one, no longer describes herein.
Implement embodiments of the invention, receive the lock notification of video acquisition device, when judging that video encoder is in idle condition, directly follow-up format conversion processing is carried out to the video image of the lock-out state that video acquisition device generates, avoid carrying out copy operation to unpressed video image, effectively can decrease the consumption of CPU and decrease taking of memory space.
See Fig. 5, for the structural representation of a kind of video process apparatus that second embodiment of the invention provides, in embodiments of the present invention, described device, except comprising receiver module 10, modular converter 11, unlock notification module 12 and coding indicating module 13, also comprises timeout treatment module 14 and status processing module 15.
Timeout treatment module 14, during for being greater than preset duration when the time not receiving the lock notification that described video acquisition device sends, judge whether exit mark is set up, if yes, the hardware resource of release busy, described hardware resource comprises cpu resource and memory source.
Status processing module 15, for judging whether described video encoder is in idle condition, if NO, sends unlock notification to described video acquisition device; If described in exit mark and be set up, the hardware resource of release busy.
Optionally, modular converter 11 for:
Determine that described video encoder is arranged in the coding thread of operating system, and inquire about the status indicator of described coding thread; Wherein, described status indicator is for representing that described coding thread is idle condition or busy condition;
Judge whether described video encoder is in idle condition according to described status indicator.
Optionally, described preset format comprises pre-set color space and/or pre-set dimension.
The embodiment of the present invention and embodiment of the method two are based on same design, and its technique effect brought is also identical, and detailed process please refer to the description of embodiment of the method two, repeats no more herein.
Implement embodiments of the invention, receive the lock notification of video acquisition device, when judging that video encoder is in idle condition, directly follow-up format conversion processing is carried out to the video image of the lock-out state that video acquisition device generates, avoid carrying out copy operation to unpressed video image, effectively can decrease the consumption of CPU and decrease taking of memory space.
See Fig. 6, for the structural representation of a kind of client that the embodiment of the present invention provides, in embodiments of the present invention, client 2 comprises video acquisition device 20, video process apparatus 21 and video encoder 22, client 2 can be the main broadcaster's client in Living Network framework, main broadcaster's client to upload onto the server equipment after being used for that the video image collected is carried out compressed encoding process, then by service equipment, the video image after process is sent to multiple spectator client.
In embodiments of the present invention, the course of work of client 2 is: video acquisition device 20 generating video image, locks described video image, and after completing lock operation, sends lock notification to video process apparatus 21; The lock notification that video process apparatus 21 receiver, video harvester 20 sends; Described lock notification is for representing that video acquisition device 20 completes the lock operation to the video image generated; Video process apparatus 21 judges whether video encoder is in idle condition, if yes, described video image is converted to the copy of preset format; After format conversion operation completes, video process apparatus 21 sends unlock notification to video acquisition device 20, and described unlock notification is used to indicate video acquisition device 20 and removes locking to described video image; After video acquisition device 20 receives described unlock notification, remove the locking to described video image; The copy of described preset format is sent to video encoder 22 by video process apparatus 21; Video encoder 22 carries out compressed encoding process to the copy of described preset format, and is uploaded onto the server by the copy of the preset format after compressed encoding process.
The detailed process related in the embodiment of the present invention see the description of embodiment of the method two, can repeat no more herein.
Implement embodiments of the invention, receive the lock notification of video acquisition device, when judging that video encoder is in idle condition, directly follow-up format conversion processing is carried out to the video image of the lock-out state that video acquisition device generates, avoid carrying out copy operation to unpressed video image, effectively can decrease the consumption of CPU and decrease taking of memory space.
One of ordinary skill in the art will appreciate that all or part of flow process realized in above-described embodiment method, that the hardware that can carry out instruction relevant by computer program has come, described program can be stored in a computer read/write memory medium, this program, when performing, can comprise the flow process of the embodiment as above-mentioned each side method.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc.
Above disclosedly be only a kind of preferred embodiment of the present invention, certainly the interest field of the present invention can not be limited with this, one of ordinary skill in the art will appreciate that all or part of flow process realizing above-described embodiment, and according to the equivalent variations that the claims in the present invention are done, still belong to the scope that invention is contained.