External audio and video input for video Development

Source: Internet
Author: User
Tags call back

External audio and video input for video Development

The external audio/video data input function meets the needs of some special applications. It is usually not used by common users. This function allows upper-layer applications to input video data and audio data to anychat, anychat then encodes and transmits the data, that is, the data of upper-layer applications is used as the data source, instead of the audio and video data collected from the local sound card and camera by anychat.

 

The external audio and video data input function allows the anychat client to have a wider range of audio and video data sources. By default, anychat collects the local sound card and camera, encode and transmit the collected audio and video data. If the video data is not collected from the standard Audio and Video hardware, the default collection function cannot meet the requirements.

 

If upper-layer applications want to process audio and video data and display the processed data remotely, they must use the external audio and video data input function.

 

To use the external audio/video data input function, follow these steps:

 

1. Enable the external audio and video input modes. After SDK Initialization is successful, it is called before entering the room:

1. // set the external audio and video input modes

2. bool bextvideoinput = 1;

3. brac_setsdkoption (brac_so_coresdk_extvideoinput, (char *) & bextvideoinput, sizeof (DWORD ));

4. bool bextaudioinput = 1;

5. brac_setsdkoption (brac_so_coresdk_extaudioinput, (char *) & bextaudioinput, sizeof (DWORD ));

2. After entering the room, set the external input audio and video data formats. You only need to call them once:

1. // set the input video format

2. brac_setinputvideoformat (brac_pix_fmt_rgb24, 320,240, 25, 0 );

3. // set the input audio format

4. brac_setinputaudioformat (1, 16000, 16, 0 );

3. After entering the room and setting the format of external input data, the upper-layer application inputs the data when preparing audio and video data.

1. // input the video frame data, each of which is 1 frame

2. brac_inputvideodata (m_lpvideobuf, dwimagesize, 0 );

3.

4. // input audio sample data, each time 100 ms

5. brac_inputaudiodata (lpsamples, dwsize, 0 );

 

 

Note:

A) Audio and video can be separated, that is, only the external video data input function is enabled, and the audio data is collected from the sound card by default using anychat. This is also possible;

B) The set video frame rate is only for Kernel encoding reference. The frame rate during transmission is subject to the actual input frame rate. For example, if it is set to 25fps, only brac_inputvideodata is called once per second, then, the kernel encoding and network transmission are only processed once per second;

C) if the external audio and video data input function is enabled, you do not need to enable the local audio and video devices after entering the room.

D) anychat synchronizes audio and video using timestamps. Upper-layer applications can specify timestamps or do not specify timestamps. The anychat kernel automatically uses the current timestamp, which is a millisecond interval, you can use the extended callback function of video data and extended callback function of audio data to call back the timestamp corresponding to audio and video data to upper-layer applications. This is necessary when upper-layer applications Process audio and video synchronization on their own.

E) See the sample code in the SRC \ Client \ c ++ \ anychatinputvideo directory of the SDK package.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.