用srs-librtmp写了一个rtmp push程序,将IPC的video data push到srs上。

首先在一台hi3518E+ar0130的摄像机上面测:
# ./rtmpmain rtmp://ossrs.net/live/livestream
Example for srs-librtmp
SRS(simple-rtmp-server) client librtmp library.
version: 3.0.3
Aptina AR0130 sensor 720P30fps init success!

很容易就导致SAMPLE_PRT("get venc stream time out, continue\n");不断打印。。。


换了一台hi3516C+imx222,测试如下:
# kill -10 1991
pid:1991 receive signal:10, prepare to exit!
# ./rtmpmain rtmp://192.168.2.9ve/main &
[1]-  Done(246)                  ./rtmpmain rtmp://192.168.2.9ve/main
# -------Sony IMX122 Sensor Initial OK!-------
VENC_StartGetStream success!register VideoCopyBuf() as callback!
SRS(simple-rtmp-server) client librtmp library.
version: 3.0.3
[1970-01-01 05:34:40.94][1996] simple handshake success
get 0 frames!-------------------------
[1970-01-01 05:34:41.03][1996] connect vhost/app success
[1970-01-01 05:34:41.07][1996] publish stream success!
[1970-01-01 05:34:41.08][1996] send h264 raw data failed. ret=3041
pid:1996 receive signal:3, prepare to exit!


[2]+  Done(253)                  ./rtmpmain rtmp://192.168.2.9ve/main

#define ERROR_H264_API_NO_PREFIXED          3041


导致这两台IPC的差异,我判断是memory。Hi3518E只有32MB给linux,而这台Hi3516C给的是64MB。
首先在128M memory的hi3516C+imx222上面跑通,可以看到视频(通过flash player)。


# ./rtmpmain rtmp://192.168.2.9/live/main &
# -------Sony IMX122 Sensor Initial OK!-------
VENC_StartGetStream success!register VideoCopyBuf() as callback!
SRS(simple-rtmp-server) client librtmp library.
version: 3.0.3
[1970-01-01 06:08:34.87][2002] simple handshake success
[1970-01-01 06:08:34.96][2002] connect vhost/app success
get 0 frames!-------------------------
[1970-01-01 06:08:34.99][2002] publish stream success!
[1970-01-01 06:08:37.02][2002] ignore duplicated pps, code=3045
[1970-01-01 06:08:39.04][2002] ignore duplicated pps, code=3045
[1970-01-01 06:08:41.09][2002] ignore duplicated pps, code=3045
[1970-01-01 06:08:43.16][2002] ignore duplicated pps, code=3045
[1970-01-01 06:08:45.09][2002] ignore duplicated pps, code=3045
[1970-01-01 06:08:47.07][2002] ignore duplicated pps, code=3045
get 200 frames!-------------------------
[1970-01-01 06:08:49.12][2002] ignore duplicated pps, code=3045
[1970-01-01 06:08:51.12][2002] ignore duplicated pps, code=3045
[1970-01-01 06:08:53.10][2002] ignore duplicated pps, code=3045


按srs作者weilin的解释,这个是可以ignore的,不要在意。


打开http://www.ossrs.net/srs.release/trunk/research/players/srs_player.html?
填入:rtmp://192.168.2.9/live/main
这样就可以播放了,srs-player,是用flash player驱动的。


----------------------------------------------
修改hi3518E+ar0130的memory分配:
setenv bootargs mem=36M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=squashfs mtdparts=hi_sfc:256K(boot),1M(kernel),1536K(rootfs),5376K(user)
insmod mmz.ko mmz=anonymous,0,0x82400000,24M anony=1 || report_error   #for 3518E use


打印:
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.8 (root@freeman-desktop) (gcc version 4.4.1 (Hisilicon_v100(gcc4.4-290+uclibc_0.9.32.1+eabi+linuxpthread)) ) #11 Sat Sep 19 21:48:56 CST 2015
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: hi3518
Ignoring unrecognised tag 0x54410010
Memory policy: ECC disabled, Data cache writeback
AXI bus clock 200000000.
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 9144
Kernel command line: mem=36M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=squashfs mtdparts=hi_sfc:256K(boot),1M(kernel),1536K(rootfs),5376K(user)
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 36MB = 36MB total
Memory: 28480k/28480k available, 8384k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc2800000 - 0xfe000000   ( 952 MB)
    lowmem  : 0xc0000000 - 0xc2400000   (  36 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc04e2000   (4968 kB)
      .text : 0xc04e2000 - 0xc07ac000   (2856 kB)
      .data : 0xc07ac000 - 0xc07c32e0   (  93 kB)
       .bss : 0xc07c3304 - 0xc07d1eb8   (  59 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:32 nr_irqs:32 32
sched_clock: 32 bits at 100MHz, resolution 10ns, wraps every 42949ms
Calibrating delay loop... 218.72 BogoMIPS (lpj=1093632)
pid_max: default: 4096 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
uart:0: ttyAMA0 at MMIO 0x20080000 (irq = 5) is a PL011 rev2
console [ttyAMA0] enabled
uart:1: ttyAMA1 at MMIO 0x20090000 (irq = 5) is a PL011 rev2
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Switching to clocksource timer1
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
squashfs: version 4.0 (2009/01/31) Phillip Lougher
JFFS2 version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered (default)
io scheduler cfq registered
brd: module loaded
Spi id table Version 1.22
Spi(cs1) ID: 0xC2 0x20 0x17 0xC2 0x20 0x17
SPI FLASH start_up_mode is 3 Bytes
Spi(cs1): 
Block:64KB 
Chip:8MB 
Name:"MX25L6406E"
spi size: 8MB
chip num: 1
4 cmdlinepart partitions found on MTD device hi_sfc
Creating 4 MTD partitions on "hi_sfc":
0x000000000000-0x000000040000 : "boot"
0x000000040000-0x000000140000 : "kernel"
0x000000140000-0x0000002c0000 : "rootfs"
0x0000002c0000-0x000000800000 : "user"
Fixed MDIO Bus: probed
himii: probed
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
hiusb-ehci hiusb-ehci.0: HIUSB EHCI
hiusb-ehci hiusb-ehci.0: new USB bus registered, assigned bus number 1
hiusb-ehci hiusb-ehci.0: irq 15, io mem 0x100b0000
hiusb-ehci hiusb-ehci.0: USB 0.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
hiusb-ohci hiusb-ohci.0: HIUSB OHCI
hiusb-ohci hiusb-ohci.0: new USB bus registered, assigned bus number 2
hiusb-ohci hiusb-ohci.0: irq 16, io mem 0x100a0000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
TCP cubic registered
NET: Registered protocol family 17
鳩reeing init memory: 4968K


            _ _ _ _ _ _ _ _ _ _ _ _
            \  _  _   _  _ _ ___
            / /__/ \ |_/
           / __   /  -  _ ___
          / /  / /  / /
  _ _ _ _/ /  /  \_/  \_ ______
___________\___\__________________


[RCS]: /etc/init.d/S00devs
[RCS]: /etc/init.d/S01udev
udevd (292): /proc/292/oom_adj is deprecated, please use /proc/292/oom_score_adj instead.
[RCS]: /etc/init.d/S80network
Hisilicon Media Memory Zone Manager
hi3518_base: module license 'Proprietary' taints kernel.
Disabling lock debugging due to kernel taint
Hisilicon UMAP device driver interface: v3.00
pa:82400000, va:c2a00000
load sys.ko for Hi3518...OK!
load viu.ko for Hi3518...OK!
ISP Mod init!
load vpss.ko ....OK!
load vou.ko ....OK!
load venc.ko for Hi3518...OK!
load group.ko for Hi3518...OK!
load chnl.ko for Hi3518...OK!
load h264e.ko for Hi3518...OK!
load jpege.ko for Hi3518...OK!
load rc.ko for Hi3518...OK!
load region.ko ....OK!
load vda.ko ....OK!
hi_i2c init is ok!
insmod: can't insert 'extdrv/ssp_ad9020.ko': No such file or directory
Hisilicon Gpio Driver OK
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
acodec inited!
insert audio
==== Your input Sensor type is ar0130 ====
Auto login as root ...
Jan  1 00:00:06 login[528]: root login on 'ttyS000'
Welcome to HiLinux.
None of nfsroot found in cmdline.
# PHY: himii:01 - Link is Up - 100/Full


# free
              total         used         free       shared      buffers
  Mem:        33448        15968        17480            0            0
 Swap:            0            0            0
Total:        33448        15968        17480
# ifconfig eth0 192.168.2.10;mkdir /tmp/nfs;mount -t nfs -o nolock 192.168.2.9:/
home/tftpboot /tmp/nfs
518E/
# export LD_LIBRARY_PATH=/tmp/nfs/ar0130_3518E/
# cd /tmp/nfs/ar0130_3518E/
# ls
LiveDemo             libstdc++.so.6.0.12  stream_chn0.h264
libstdc++.so         rtmpmain             stream_chn1.h264
libstdc++.so.6       sample_venc          stream_chn2.h264
# ./rtmpmain rtmp://192.168.2.9/live/main &
# Aptina AR0130 sensor 720P30fps init success!
VENC_StartGetStream success!register VideoCopyBuf() as callback!
SRS(simple-rtmp-server) client librtmp library.
version: 3.0.3
[1970-01-01 00:02:55.45][538] simple handshake success
[1970-01-01 00:02:55.50][538] connect vhost/app success
[1970-01-01 00:02:55.54][538] publish stream success!



# ps
  PID USER       VSZ STAT COMMAND
    1 root      1708 S    init
    2 root         0 SW   [kthreadd]
    3 root         0 SW   [ksoftirqd/0]
    4 root         0 SW   [kworker/0:0]
    5 root         0 SW   [kworker/u:0]
    6 root         0 SW   [rcu_kthread]
    7 root         0 SW<  [khelper]
    8 root         0 SW   [kworker/u:1]
   81 root         0 SW   [sync_supers]
   83 root         0 SW   [bdi-default]
   85 root         0 SW<  [kblockd]
   97 root         0 SW   [khubd]
  113 root         0 SW<  [rpciod]
  114 root         0 SW   [kworker/0:1]
  117 root         0 SW   [kswapd0]
  165 root         0 SW   [fsnotify_mark]
  170 root         0 SW<  [nfsiod]
  178 root         0 SW<  [crypto]
  228 root         0 SW   [mtdblock0]
  233 root         0 SW   [mtdblock1]
  238 root         0 SW   [mtdblock2]
  243 root         0 SW   [mtdblock3]
  246 root         0 SW   [romblock0]
  249 root         0 SW   [romblock1]
  252 root         0 SW   [romblock2]
  255 root         0 SW   [romblock3]
  292 root       872 S <  udevd --daemon
  528 root      1732 S    -sh
  538 root     28144 S    ./rtmpmain rtmp://192.168.2.9/live/main
  541 root      1708 R    ps

# 此时用srs-player可以看到流了。播放10分钟正常!
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
srs-librtmp一个开源的RTMP协议库,可以用于推流和拉流。如果想要使用srs-librtmp推流摄像头数据,可以按照以下步骤进行实现: 1. 打开摄像头获取视频数据,可以使用OpenCV库或其他类库进行实现。 2. 使用srs-librtmp创建RTMP连接,并发送RTMP头信息。 3. 设置RTMP流媒体的参数,包括视频编码格式、帧率、分辨率等。 4. 循环发送视频数据,将视频数据封装为RTMP包,并通过RTMP连接发送出去。 下面是C++的代码示例: ```cpp #include <iostream> #include <opencv2/opencv.hpp> #include "srs_librtmp.h" int main() { // 打开摄像头 cv::VideoCapture cap(0); if (!cap.isOpened()) { std::cerr << "Failed to open camera!" << std::endl; return -1; } // 创建srs-librtmp连接 srs_rtmp_t rtmp = srs_rtmp_create("rtmp://localhost/live/test", NULL); // 发送RTMP头信息 srs_rtmp_handshake(rtmp); // 设置RTMP流媒体参数 srs_rtmp_connect_app(rtmp); srs_rtmp_publish_stream(rtmp); srs_rtmp_avc_sequence_header(rtmp, NULL, 0, NULL, 0); // 发送视频数据 cv::Mat frame; while (cap.read(frame)) { // 将视频数据封装为RTMPsrs_rtmp_packet_t pkt; srs_rtmp_packet_init(&pkt); pkt.payload = frame.data; pkt.size = frame.total() * frame.elemSize(); pkt.timestamp = srs_utils_time_ms(); pkt.type = SRS_RTMP_TYPE_VIDEO; // 发送RTMPsrs_rtmp_write_packet(rtmp, &pkt); // 释放RTMP包资源 srs_rtmp_packet_free(&pkt); // 等待一段时间 cv::waitKey(30); } // 关闭srs-librtmp连接 srs_rtmp_destroy(rtmp); return 0; } ``` 需要注意的是,在实际应用中,需要根据摄像头的实际情况,调整视频编码格式、帧率、分辨率等参数。此外,srs-librtmp还支持推送音频数据,可以根据需要进行实现。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

草根大哥

进军大神程序员路上,谢谢支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值