基于h.264编码的视频监控(软编码)

本文介绍了一种基于H.264编码的视频监控系统的搭建过程,包括x264和Live555在开发板上的移植、摄像头数据的采集与转换、实时传输协议(RTSP)的应用及VLC播放器的配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基于H.264(x.264)编码的视频监控

大概流程为:

开发板:

            1.读取摄像头

            2.进行rtsp传输(live555)

            3.不断的进行2和3.

pc机:

           利用vlc进行接收到板子发送过来的数据并显示。

 

第一步移植x264到开发板:(当然我们可以交叉编译为静态链接,然后把可执行程序拷贝到开发板就可以)

参考别人的步骤:

http://blog.youkuaiyun.com/liuzongming1988/article/details/8234893

第二部移植live555到开发板:

      参考别人的步骤:

http://blog.youkuaiyun.com/lawishere/article/details/8182952

 

注:第一步和第二步已经是很早之前完成的好像是这么回事。

        第二步主要是把Live555MediaServer这个可执行文件拷贝到开发板。

 

第三步就是主要工作了:

这里主要是用了一个小技巧,在目录下创建一个有名fifo把读取摄像头数据的数据可以发送到live555MediaServer这个程序。

fifo就起到一个桥梁的作用。

 

在工作录下有两个程序(3个文件)

1.读取摄像头程序

2.live555MediaServer

3.fifo文件。

 

假设我们所创建的fifo名称为test.264

 

在pc机(我的为ubuntu)下安装vlc

打开vlc

 

选择Open NetWork Stream...

 

 

如上所设置,IP则开发板的IP,至于端口8000 默认的Live555MedisServer是8000的

test.264就是刚才开发板所创建的fifo文件名称。

 

 

我擦、这么晚了。。回宿舍睡觉去了。。等有空了在把代码和开发板的一些相关情况发出来。

今天也在6410上进行了硬编码的了,在pc机则用ffmpeg进行解码 opencv显示。

到时候在一起发上来。~~~~

学生党 伤不起啊!

 

继续!!!!!

 

我所用的摄像头采集的图像为yuv422(交叉YUVYUVYUV)格式,所以需要进行

格式的转换,代码里面有个函数为

yuv422Toyuv420I

作用就是格式的转换,至于怎么读取摄像头数据的话就不多说了(v4l2)。。。

 

软件编码的话可以详细的看代码里面,需要说明的是一个函数

x264_param_default_preset(param, "ultrafast", "zerolantency");

参数"ulrtafast"和"zerolantency"在x264源码包下common目录下有一个文件为common.c

里面有函数

void x264_param_default(x264_param_t *param);

static int x264_param_apply_preset(x264_param_t *param, const char *preset);

此时的const char *preset = "ultrafast";

static int x264_param_apply_tune(x264_param_t *param, const char *tune);

此时的const char *tune = "zerolantency";

可以到此源代码下观察还会有其他选项,对于实时监控则用此两个参数即可。

 

#  ./live555Server 

 

输入rtsp://172.19.69.80/test.264

 

IP为pc机上的IP  test.264就是fifo

 

效果图就是如下所示:

看到它的窗口名称就是刚才vlc上所设置的。

流格式:rtsp

开发板IP:172.19.69.50

端口:  8000

文件名: test.264

 

 

 

附上开发板上运行的客户端程序:

http://download.youkuaiyun.com/detail/darling54454/7439873

 

 

 

 

 

H264编码开源代码 Video Usability Information (VUI) Guide by Christian Heine ( sennindemokrit at gmx dot net ) 1. Sample Aspect Ratio ----------------------- * What is it? The Sample Aspect Ratio (SAR) (sometimes called Pixel Aspect Ratio or just Pel Aspect Ratio) is defined as the ratio of the width of the sample to the height of the sample. While pixels on a computer monitor generally are "square" meaning that their SAR is 1:1, digitized video usually has rather odd SARs. Playback of material with a particular SAR on a system with a different SAR will result in a stretched/squashed image. A correction is necessary that relies on the knowledge of both SARs. * How do I use it? You can derive the SAR of an image from the width, height and the display aspect ratio (DAR) of the image as follows: SAR_x DAR_x * height ----- = -------------- SAR_y DAR_y * width for example: width x height = 704x576, DAR = 4:3 ==> SAR = 2304:2112 or 12:11 Please note that if your material is a digitized analog signal, you should not use this equation to calculate the SAR. Refer to the manual of your digitizing equipment or this link instead. A Quick Guide to Digital Video Resolution and Aspect Ratio Conversions http://www.iki.fi/znark/video/conversion/ * Should I use this option? In one word: yes. Most decoders/ media players nowadays support automatic correction of aspect ratios, and there are just few exceptions. You should even use it, if the SAR of your material is 1:1, as the default of x264 is "SAR not defined".
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值