[转]GStreamer资料(摄像头采集,视频保存,远程监控)DVR

2023-05-16

http://blog.csdn.net/wzwxiaozheng/archive/2010/12/26/6099397.aspx

GStreamer资料整理(包括摄像头采集,视频保存,远程监控,流媒体RTP传输)

1,gstreamer开发手册,gstreamer官网(这些都不用说了吧)

 

2,gst-launch的用法,这也不用说了吧。(白菜,鸡蛋,西红柿,砖头,鼠标……..)

 

3,http://blog.chinaunix.net/u/6646/showart_164960.html

lqplayer--基于gstreamer和qt的linux下的简单播放器。

实现了基于QT+GST的一个播放器。我下载源码后编译出现了几个BUG,如下:

(1),源码编译不通过,media.cpp下有个地方大概是第54行,g_free(tag_list);,把这个地方注释掉,资源没有申请到还free,当然出错了。(此BUG花了我几十分钟的时间)

(2),界面上的按钮都不能使用,pthread_create(&tid, NULL, cb_run_loop, this);这句要注释掉,我们的主循环使用的是QT的主循环,这个就不必了吧,要不就进GST的死循环了。(这个小BUG花了我某个星期六的一个清晨)

在这里还要说一下快放和慢放的问题:

gint64 value = m_frontend->sliderTiming->value();

 m_speed = m_speed+1;

 

        gst_element_seek (m_pipeline, m_speed, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,

                          GST_SEEK_TYPE_SET, value * GST_MSECOND*1000  ,

                          GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);

 

当m_speed为负值时可实现倒放,但是不稳定,仅几秒钟就会出现GST_MESSAGE_EOS。

 

当m_speed为负值时,我这样实现

gst_element_seek (m_pipeline, m_speed, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,

                          GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE  ,

                          GST_SEEK_TYPE_SET, value * GST_MSECOND*1000);

无非就是调了个位置,效果好了许多,不妨试一下。(为啥呢,我也不知道,此BUG花了我三四天的时间)

 

  4,http://www.pierrox.net/dvr/releases/dvr-3.99.4.tar.bz2

   基于QT3的,实现了GST的采集编码,并保存为avi文件。总感觉这东西写的有些地方让人不爽,又说不出是哪里来。

 

  5,http://blog.chinaunix.net/u3/94516/showart_2269637.html

    GStreamer发送视频/音频流至服务器端并播放、保存。

    Client实现了gstreamer视频文件的RTP发送,写个vlc的配置文件,使用vlc打开可以在网络上进行观看(vlc的使用和配置文件使用可以从网上搜一下,还是比较多的),效果还不错.源码实现时稍显繁琐。Decodebin的连接要注意一下。还有就是gstrtpbin的连接要仔细看一下,刚开始感觉有些麻烦,错误了好几次。后来才明了了。(此功能的源码实现花了我一整天的时间,早9-晚11)

    Server端,试了,没成功,后来就没仔细看。

 

  6,http://www.since1985i.com/tag/gstreamer

    Gstreamer实现摄像头采集并显示。不过是命令行下的,相对上面RTP网络的例子来说,这个用源码实现可就是小case了吧。同样结合上面RTP传输的例子,也同样使用vlc来播放,就可以实现网络摄像头。(哇塞,网络摄像头耶!远程监控耶!摄像头采集花了我两个月的时间吧,当时还年轻,后来发现是摄像头的问题,当然,这个也算是BUG,总结经验就是十几块的摄像头是靠不住的)

 

总结:上面有了摄像头采集保存的例子,有利用QT+GST实现播放器的例子,有RTP传输的例子,这样就可以实现用QT做界面,Gstreamer做后台的集采集编码保存,还有本地视频回放,网络视频监控于一体的DVR软件了。嗯,功能还挺全的。有意思吧~~

 

结束语:向以上几位哥们儿致敬。刚开始做民工,有你们的分享我很庆幸。

 

==========================================================================================

==================下边这个实在看不懂 留下研究=============================================

 

[转载]关于GStreamer的一个牛X网页(字符叠加,画中画,屏墙) 

http://blog.csdn.net/wzwxiaozheng/archive/2011/01/12/6130818.aspx

在网上闲逛搜GST,不小心发现了一个网址

http://wiki.oz9aec.net/index.php/Gstreamer_cheat_sheet

是WIKI的GStreamer小抄,应该是这样翻译吧。

看了这个网址我就笑了。

上面讲了gstreamer字符叠加,画中画,屏墙等的实现,附带实现的命令,这样实现源码就小case了。

本文描述了gstreamer可实现的功能,主要是针对本硬盘录像机软件功能来说的,以gst-launch命令行的方式,简洁明了,并附有插图。大部分是网络资源,小部分是自己研究。难免有疏漏,敬请指正。

 

参考网址:

1,http://wiki.oz9aec.net/index.php/Gstreamer_cheat_sheet#Video_Wall:_Live_from_Pluto

,gstreamer实现摄像头采集 ,gstreamer实现视频显示 ,将4/3显示转换为16/9 ,实现h264编码并保存 ,将保存的视频播放,gstreamer实现视频截图 ,gstreamer实现字符叠加 ,gstreamer实现RTP网络服务端及客户端 ,gstreamer实现画中画,gstreamer实现屏墙效果

 

 

1,gstreamer实现摄像头采集:

gst-launch v4l2src ! xvimagesink   gst-launch v4l2src !  video/x-raw-yuv,width=320,height=240,framerate=20/1 ! xvimagesink(未通过)   gst-launch v4l2src ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=320,height=240 ! xvimagesink (通过,)

 

2,gstreamer实现视频显示

gst-launch videotestsrc ! ximagesink (通过) 

 

  

3,gstreamer实现字符叠加

gst-launch videotestsrc ! timeoverlay ! xvimagesink (通过)   gst-launch -v videotestsrc ! video/x-raw-yuv, framerate=25/1, width=640, height=360 ! \    timeoverlay halign=left valign=bottom text="Stream time:" shaded-background=true ! xvimagesink (通过) 添加timeoverlay的效果,timeoverlay基于textoverlay 
  其它一些相关元件的使用: gst-launch videotestsrc ! cairotimeoverlay ! xvimagesink  (未通过) gst-launch videotestsrc ! clockoverlay ! xvimagesink (通过) gst-launch videotestsrc ! clockoverlay halign=right valign=bottom shaded-background=true time-format="%Y.%m.%D" ! ffmpegcolorspace ! ximagesink (通过) gst-launch -e v4l2src ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=1280,height=720,framerate=5/1 ! \    ffmpegcolorspace ! \    timeoverlay halign=right valign=top ! clockoverlay halign=left valign=top time-format="%Y/%m/%d %H:%M:%S" ! \    tee name="splitter" ! queue ! xvimagesink sync=false splitter. ! \    queue ! videorate ! video/x-raw-yuv,framerate=1/1 ! \    theoraenc bitrate=256 ! oggmux ! filesink location=webcam.ogg (未通过) 

 

4,gstreamer实现RTP网络服务端及客户端

客户端: gst-launch -v gstrtpbin name=rtpbin latency=100 , udpsrc caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, ssrc=(uint)340005641,clock-base=(uint)2625017333, payload=(int)96,  seqnum-base=(uint)5894" port=5000 ! queue ! rtpbin.recv_rtp_sink_0  rtpbin. ! rtph264depay ! queue ! ffdec_h264 ! videoscale ! autovideosink udpsrc port=5001 ! queue ! rtpbin.recv_rtcp_sink_0 rtpbin.send_rtcp_src_0 ! queue ! udpsink port=5005  sync=true  async=false (在windows底下成功,linux应该也没问题)   服务端: gst-launch -v  gstrtpbin name=rtpbin latency=100 \         uridecodebin uri=file:///home/miia/test.avi name=decoder \         decoder. ! tee name=tee0 \         tee0. ! queue2 ! ffmpegcolorspace ! videoscale ! autovideosink \         tee0. ! queue2 ! ffmpegcolorspace ! x264enc ! rtph264pay pt=96 ! queue2 ! rtpbin.send_rtp_sink_0 \         rtpbin.send_rtp_src_0 ! queue2 ! udpsink host=192.168.0.105 port=5000  async=false\         rtpbin.send_rtcp_src_0 ! queue2 ! udpsink host=192.168.0.105 port=5001 async=false\         udpsrc port=5005 ! queue2 ! rtpbin.recv_rtcp_sink_0 \          \         decoder. ! tee name=tee1 \         tee1. ! queue2 ! audioconvert ! autoaudiosink \         tee1. ! queue2 !  audioconvert ! faac !     rtpmp4apay pt=96 ! queue2 ! rtpbin.send_rtp_sink_1 \         rtpbin.send_rtp_src_1 ! queue2 ! udpsink host=192.168.0.105 port=5002  async=false\         rtpbin.send_rtcp_src_1 ! queue2 ! udpsink host=192.168.0.105 port=5003 async=false\         udpsrc port=5007 ! queue2 ! rtpbin.recv_rtcp_sink_1 (在linux底下成功)  
From man gst-launch: Network streaming       Stream video using RTP and network elements.       gst-launch v4l2src ! video/x-raw-yuv,width=128,height=96,format='(fourcc)'UYVY ! ffmpegcolorspace ! ffenc_h263       ! video/x-h263 ! rtph263ppay pt=96 ! udpsink host=192.168.1.1 port=5000 sync=false       Use this command on the receiver       gst-launch  udpsrc  port=5000 ! application/x-rtp, clock-rate=90000,payload=96 ! rtph263pdepay queue-delay=0 !       ffdec_h263 ! xvimagesink    

 

5,gstreamer实现视频截图

  gst-launch -e v4l2src ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=1280,height=720,framerate=5/1 ! ffmpegcolorspace ! \    timeoverlay halign=right valign=bottom ! clockoverlay halign=left valign=bottom time-format="%Y/%m/%d %H:%M:%S" ! \    videorate ! video/x-raw-rgb,framerate=1/1 ! ffmpegcolorspace ! pngenc snapshot=false ! multifilesink location="frame%05d.png" (未通过) 

 

6,gstreamer实现画中画效果

gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! videomixer name=mix ! \    ffmpegcolorspace ! xvimagesink videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix. (通过,效果跟图片一样) 在一个窗口中同时显示两个视频界面 
  gst-launch videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! \   videomixer name=mix sink_1::xpos=20 sink_1::ypos=20 sink_1::alpha=0.5 sink_1::zorder=3 sink_2::xpos=100 sink_2::ypos=100 sink_2::zorder=2 ! \    ffmpegcolorspace ! xvimagesink videotestsrc pattern=13 ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! mix. \    videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix. 设置视频界面的位置和效果,alpha透明效果 
gst-launch \    videomixer name=mix sink_1::xpos=20 sink_1::ypos=20 sink_1::alpha=0.5 sink_1::zorder=3 sink_2::xpos=100 sink_2::ypos=100 sink_2::zorder=2 ! \    ffmpegcolorspace ! xvimagesink \    videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 !  mix.sink_0 \    videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 !  mix.sink_1 \    videotestsrc pattern=13 ! video/x-raw-yuv, framerate=10/1, width=200, height=150 !  mix.sink_2 (通过,效果非常好,跟图片一样) 
gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 !  videobox border-alpha=0 top=-20 left=-25 ! \    videomixer name=mix ! ffmpegcolorspace ! xvimagesink videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix.   Videobox的使用: 
  gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! \   videobox border-alpha=0  alpha=0.6 top=-20 left=-25 ! videomixer name=mix ! ffmpegcolorspace ! xvimagesink \   videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix. (通过) Videobox和alpha效果 
  gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! \    videobox border-alpha=1.0 top=-2 bottom=-2 left=-2 right=-2 ! videobox border-alpha=0 alpha=0.6 top=-20 left=-25 ! \    videomixer name=mix ! ffmpegcolorspace ! xvimagesink videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix. (通过,效果略有出入,不透明) border-alpha,加边框的透明效果 
  gst-launch -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink \    videotestsrc pattern=1 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! videobox border-alpha=0 top=0 left=0 ! mix. \    videotestsrc pattern=15 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! videobox border-alpha=0 top=0 left=-320 ! mix. \    videotestsrc pattern=13 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! videobox border-alpha=0 top=-180 left=0 ! mix. \    videotestsrc pattern=0 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! videobox border-alpha=0 top=-180 left=-320 ! mix. \    videotestsrc pattern=3 ! video/x-raw-yuv, framerate=5/1, width=640, height=360 ! mix. (通过) 

 

7,gstreamer实现屏墙效果

   gst-launch -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink \    videotestsrc pattern=0 ! video/x-raw-yuv, framerate=1/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM1" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-50 ! mix. \    videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=1/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM2" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-450 ! mix. \    videotestsrc pattern=13 ! video/x-raw-yuv, framerate=1/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM3" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-850 ! mix. \    multifilesrc location="pluto.jpg" caps="image/jpeg,framerate=1/1" ! jpegdec ! \     textoverlay font-desc="Sans 26" text="Live from Pluto" halign=left shaded-background=true auto-resize=false ! \      ffmpegcolorspace ! video/x-raw-yuv,format=\(fourcc\)AYUV ! mix. (修改几个参数后,通过,但效果不好,根据环境不同,所修改的参数不同。在本次试验中,把最后一行的format=\(fourcc\)AYUV去掉,则通过。本来应该显示三个画面,这次经验显示不全,不知道什么原因。不过经调试三个画面都显示了,但是,图片被黑框档掉一块儿,没有示例图片好看) 
  
可执行的命令行:(通过,需多次执行) gst-launch -e videomixer name=mix ! ffmpegcolorspace ! ximagesink \   videotestsrc pattern=0 ! video/x-raw-yuv, framerate=10/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM1" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-850 ! mix. \    videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM2" valign=top halign=left shaded-background=true ! \     videobox border-alpha=0 top=-200 left=-450 ! mix. \    videotestsrc pattern=13 ! video/x-raw-yuv, framerate=10/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM3" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-50 ! mix. \    multifilesrc location="pluto.jpg" caps="image/jpeg,framerate=10/1" ! jpegdec ! \      textoverlay font-desc="Sans 26" text="Live from Pluto" halign=left shaded-background=true auto-resize=false ! \      ffmpegcolorspace ! video/x-raw-yuv ! mix.

转载于:https://www.cnblogs.com/subo_peng/p/4675384.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

[转]GStreamer资料(摄像头采集,视频保存,远程监控)DVR 的相关文章

随机推荐

  • 兄弟们,请求支援,怎么实现互通,全部都互通的

    转载于 https blog 51cto com 14155986 2337267
  • FIFO算法与LRU算法软考试题

    转载于 https www cnblogs com kungfupanda archive 2009 12 25 1632106 html
  • iOS 网络/本地 图片 按自定义比例缩放 不失真 方法

    我尝试了很多种方法 xff0c 终于 xff0c 设计了一个方法 xff0c 能按自己规定的大小压缩 还没失真 如果以后不好用 我再升级 分享给大家 xff1a 43 CGRect scaleImage UIImage image toSi
  • java 输入输出 函数对象构造

    输入输出 输入字符串 不包括最后的换行符 39 n 39 import java io BufferedReader import java io IOException 输入字符一个char import java io InputStr
  • Python 3 加密简介

    Python 3 的标准库中是没多少用来解决加密的 xff0c 不过却有用于处理哈希的库 在这里我们会对其进行一个简单的介绍 xff0c 但重点会放在两个第三方的软件包 xff1a PyCrypto 和 cryptography 上 xff
  • grep 命令的基本使用

    环境变量 xff1a 定义用户的工作环境某个方面的属性 文本文件的查看命令 xff1a cat 连接 能够将后面跟的多个文件的内容 xff0c 依次显示 cat n 在显示时出现行号 E 显示行结束符 v 显示非打印字符不显示制表符tab
  • innodb Cardinality学习笔记

    github 传送门 链接描述 欢迎过来star呀 背景 1 之前对innodb的Cardinality没概念 xff0c 只知道要高选择性的列上建索引 xff0c 比如用户名而不是性别 xff0c 因为性别区分度不高 xff0c 但是这过
  • K8S组件运行原理详解总结

    一 看图说K8S 先从一张大图来观看一下K8S是如何运作的 xff0c 再具体去细化K8S的概念 组件以及网络模型 从上图 xff0c 我们可以看到K8S组件和逻辑及其复杂 xff0c 但是这并不可怕 xff0c 我们从宏观上先了解K8S是
  • ubuntu中apt-get的常用命令。

    使用以下命令清理系统垃圾 sudo apt get autoclean 清理旧版本的软件缓存 sudo apt get clean 清理所有软件缓存 sudo apt get autoremove 删除系统不再使用的孤立软件 xff1d x
  • Qt之设置QWidget背景色

    简述 QWidget是所有用户界面对象的基类 xff0c 这意味着可以用同样的方法为其它子类控件改变背景颜色 Qt中窗口背景的设置 xff0c 下面介绍三种方法 使用QPalette 使用Style Sheet绘图事件 一般我不用QSS设置
  • 计算机机房英文术语,【数据中心】数据中心常见中英术语及解释

    原标题 xff1a 数据中心 数据中心常见中英术语及解释 一 常见中文术语 1 数据中心 为一个建筑群 建筑物或建筑物中的一个部分 xff0c 主要用于容纳设置计算机房及其支持空间 2 进线间 外部缆线引入和电信业务经营者安装通信设施的空间
  • C#学习之接口

    什么是接口 xff1f 其实 xff0c 接口简单理解就是一种约定 xff0c 使得实现接口的类或结构在形式上保持一致 个人觉得 xff0c 使用接口可以使程序更加清晰和条理化 xff0c 这就是接口的好处 xff0c 但并不是所有的编程语
  • neo1973 audio subsystem

    fhttp wiki openmoko org wiki Neo 1973 audio subsystem using Bluetooth headset with GSM NOTE none of this works with GTA0
  • 程序员面试必备书单

    点击关注异步图书 xff0c 置顶公众号 每天与你分享 IT好书 技术干货 职场知识 Tips 参与文末话题讨论 xff0c 即有机会获得异步图书一本 世上最快乐的事 xff0c 莫过于为理想奋斗 一个满意的工作 xff0c 便是为理想奋斗
  • vnc linux 终端打不开,vnc连接后只能看到终端

    我在windows安装了VNC Viewer xff0c 远程链接ubunt12 04服务器 xff0c 发现远程桌面只有一个终端 xff0c 没有桌面 从网上查了一些资料 xff0c 问题得以解决 xff0c 记录如下 xff1a 修改
  • ubuntu11.04下CUDA4.0的安装与配置

    ubuntu11 04下CUDA4 0的安装与配置 1 xff1a 下载CUDA 4 0 安装官网最新的显卡驱动 xff1a 安装方法可以参考 xff1a Ubuntu11 04下安装Nvidia显卡驱动的方法 然后从NVIDIA网站 xf
  • MySQL中如何定位DDL被阻塞的问题

    在生产环境中 xff0c 执行了一个DDL xff0c 发现很久都没有执行完 xff0c 是不是被阻塞了 xff1f 要怎么解决 xff1f 实际上 xff0c 如何解决DDL阻塞的问题 xff0c 是MySQL中一个共性且高频的问题 下面
  • oracle中的index函数,Oracle中的索引详解(整理)

    一 ROWID的概念 存储了row在数据文件中的具体位置 xff1a 64位 编码的数据 xff0c A Z a z 0 9 43 和 xff0c row在数据块中的存储方式 SELECT ROWID last name FROM hr e
  • KM算法学习笔记

    二分图定义 图的顶点恰好可以分成两个集合 xff0c 同一个集合内的顶点间不允许有边 xff0c 处在不同集合的顶点允许有边相连 问题分类 最大匹配问题 xff1a 匈牙利算法 Hopcroft Karp算法最优权值匹配问题 xff1a K
  • [转]GStreamer资料(摄像头采集,视频保存,远程监控)DVR

    http blog csdn net wzwxiaozheng archive 2010 12 26 6099397 aspx GStreamer资料整理 包括摄像头采集 视频保存 远程监控 流媒体RTP传输 1 gstreamer开发手册