X264编码3 实时编码(网络摄像头)

    继续我们的X264编码,第一篇我们完成了对本地文件的编码 点击打开链接,第二篇我们可以实时对USB摄像头进行编码 点击打开链接,在这里,我们介绍第三个:实时对网络摄像头进行编码。

    我这里用的是海康威视网络摄像头,关于怎么调用它,可以参考博客:点击打开链接


    编码部分都是换汤不换药,我们直接给出源代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include "Windows.h"
#include "HCNetSDK.h"
#include "plaympeg4.h"
#include <opencv2\opencv.hpp>
#include "cv.h"
#include "highgui.h"
#include <time.h> 
#include "stdafx.h"
#include "stdint.h" 
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <stdio.h>
#include <string>

using namespace cv;
using namespace std;

extern "C"
{
#include "x264.h"
#include "x264_config.h"
};

LONG nPort = -1; 
char filename[100];
volatile int gbHandling = 3;
int ct = 0;
int w = 640;
int h = 480;

int yuv_bufLen = w * h * 3 / 2;
unsigned char* pYuvBuf = new unsigned char[yuv_bufLen];
FILE* pFileOut = fopen("result.yuv", "w+");
Mat dst;

int MyYuvtoH264(int width, int height, string filename)
{
	int fps = 15;
	size_t yuv_size = width * height * 3 / 2;
	x264_t *encoder;
	x264_picture_t pic_in, pic_out;
	uint8_t *yuv_buffer;

	x264_param_t param;
	x26
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值