C # video Surveillance series (5): client-send string and video to server (data capture)

Source: Internet
Author: User
Tags bool

Send a string to the server

This function is very simple and it doesn't feel practical.

1.vc++ Code:

MP4_ClientCommandtoServer((LPCTSTR)ctemp,sendcont,400);

2.c# Code:

PcHikClient.MP4_ClientCommandtoServer("192.168.0.188", "服务器你好:)", 14);

A description of this method can be found from the API documentation: the first parameter is the IP of the server, the second is the string to send, and the third is the length of the string.

Second, the client to video recording

Client video recording from the API document (Hikvision Card Network Development Package Programming manual V4.7) can be seen by the mp4_clientstartcapture or Mp4_clientstartcapturefile function to achieve this function, from VC + + source can see that he is implemented with the latter, simple and easy, but the server side does not have this function-_-#. But Mp4_clientstartcapture is more flexible by recalling its own write storage code, and can implement additional functions such as statistics, which only provide VC + + corresponding to the C # version of the Mp4_clientstartcapturefile

1.vc++ Code:

//开始录像
    if (nn1 >= 0)
    {
        sprintf(filename,"d:\\mp4test1_%d.mp4",capcount);
        MP4_ClientStartCaptureFile(nn1,filename);
        //MP4_ClientStartCapture(nn1);
    }
    //关闭录像
    if (nn1>=0)
        MP4_ClientStopCapture(nn1);

2.c# Code:

/// <summary>
        /// 开始录像
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStartCap_Click(object sender, EventArgs e)
        {
            PcHikClient.MP4_ClientStartCaptureFile(cs, "D:\\mp4test1_0.mp4");
        }

        /// <summary>
        /// 停止录像
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStopCap_Click(object sender, EventArgs e)
        {
            PcHikClient.MP4_ClientStopCapture(cs);
        }

The method is simple, but notice that the previous post's mp4_clientstartcapturefile parameter corresponds to an error, otherwise the file cannot be created and returns false, and the previous SDK encapsulation API has been updated with the following specific error:

VC + + Prototype:

BOOL  __stdcall MP4_ClientStartCaptureFile(LONG StockHandle, LPTSTR FileName);

Previous version:

public static extern bool MP4_ClientStartCaptureFile(long StockHandle, string FileName);

Change after version:

public static extern bool MP4_ClientStartCaptureFile(int StockHandle, string FileName);

Note that the Stockhandle parameter data type changes. The Mp4_clientstopcapture parameter is also a long data type, but it doesn't matter if it doesn't change to int.

Legacy issues

The saved MP4 file shows the total playback time and the actual playback time is always 3 seconds, such as total time is 48 seconds, and broadcast to 45 No, more strange, but little impact:

End

The content of this chapter is still simple, error still occurs in the data type corresponding, so we need to pay more attention to:

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.