Today, we need to set some attributes of the camera component in flex. Later, we found that the definition was not very high, so after a long morning, we set a lot of parameters. In fact, we found that there were some existing settings in the manual, depressed! However, I have set several useful and necessary attributes for applications in my own program, which is actually very simple!
Take this example:
Camera. setmode (320,240, 15 );
It is to set a bandwidth consumption of 320 in width, 240 in height, and 15 FPS in playback speed:
(320*240*15)/1000000 = 1.2 (mbps) = 1152000 (BPS) // 1000000 is a 1024*1024 trade-off statement, that is, 1000*1000;
For the bandwidth consumed, the bandwidth calculation we can understand is:
320*240*15/8000 = 144 K/s (that is, 144 K per second) // it can be seen that the video size and playback ratio are related to the bandwidth ~
Next we can set the video quality as follows:
Because function setquality (bandwidth: int, quality: INT) uses different units during the setting, bandwidth uses kbps instead of bps, to convert (8 bits = 1 byte), convert1152000/8 = 144000 (Kbps ),
You must set the playback quality as follows:
Camera. setquality (144000,85); // (85 is a conventional video quality, it is best to use this value)
The next step is to set the key frame of the video to be transmitted. You can set it based on the actual bandwidth. Remember: the smaller the key frame value, the larger the bandwidth usage, and the larger the key frame value, the smaller the bandwidth usage. Value: for example, 1 indicates that each frame is a key frame. If each frame needs to be transmitted, the bandwidth usage will be increased, and so on. The acceptable values are 1 to 48. If the image quality requirement is not high, you can set it to 48. If the quality requirement is high, it is best to set it to around 5-10;
Camera. setkeyframeinterval (48 );
For cameras, the optimal imaging ratio is4: 3So it is best to set the proportion of the imaging according to the minimum proportion!
The following are typical built-in settings for network cameras and digital video cameras:
The local video capture resolution is generally set to a ratio of 4 to 3 (width and height. Although there is no need for a proportional operation, it is not a bad idea when you get started. With a ratio, You can optimize what your camera sees.
Common settings of Flex camera:
Open the camera:
Camera camera = camera. getcamera ();
// Set the camera capture mode to the local mode that best meets the specified requirements.
Camera. setmode (240,180, 15 );
// Specify the Video Frames (key frames) that are completely transmitted without video compression algorithms performing interpolation ). Camera. setkeyframeinterval (60 );
// Set the maximum bandwidth per second or the image quality required for the input signal of the current output video
Camera. setquality (144,85 );
Video video = new video (camera. Width * 2, camera. Height * 2 );
// The camera object that is capturing video data
Video. attachcamera (CAMERA );
Disable the camera:
nullIndicates that the camera is being used by another application, or the camera is not installed on the system.
Camera = camera. getcamera (null );
Camera = NULL;
// The camera object that is capturing video data. To disconnect the video object, pass
Video. attachcamera (null );
Record this article and forget it.