当前位置: 首页 > 文档资料 > SRS Wiki 中文文档 >

SRS for linux-arm

优质
小牛编辑
116浏览
2023-12-01

arm芯片上,如何使用SRS?一般arm上的硬件可以获取到h.264裸码流。有几个方案:

  • arm推送RTMP到SRS:从arm上将h.264裸码流包装成flv流,使用srs-librtmp,或者librtmp,将flv格式的包以RTMP发送到SRS。
  • arm上运行SRS:在arm上运行SRS,使用上面两个方案将h.264裸码流推送到arm上的SRS。客户端或者RTMP边缘直接从arm上的SRS源站取RTMP流。

Why run SRS on ARM?

ARM跑SRS主要原因:

  • arm设备,像摄像头,比较多,譬如一万个摄像头,如果有中心服务器,都往上面推,中心服务器就完蛋了。
  • 用户看摄像头时,一般需要装插件,一般摄像头只能出rtmp。所以没法用浏览器flash直接看。所以arm上跑个srs,就可以让用户直接打开。
  • arm上跑srs,每个摄像头都是服务器,相当于分布式服务器。不过都是源站。

Ubuntu Cross Build SRS

详细步骤请参考这里

Use Other Cross build tools

若需要使用其他的交叉编译工具,或者其他的CPU体系或OS,也可以支持,参考这里

RaspberryPi

SRS可以直接在RespberryPI上编译和运行,不用交叉编译。

Armel and Armhf

有时候总是碰到Illegal instruction,那是编译器的目标CPU太高,虚拟机的CPU太低。 参考:http://stackoverflow.com/questions/14253626/arm-cross-compiling

写一个简单的测试程序,测试编译环境:

/*
 arm-linux-gnueabi-g++ -o test test.cpp -static
 arm-linux-gnueabi-strip test
*/
#include <stdio.h>

int main(int argc, char** argv) {
    printf("hello, arm!\n");
    return 0;
}

编译出test后,使用工具查看目标CPU:

arm-linux-gnueabi-readelf --file-header --arch-specific test
运行结果如下:
  Machine:                           ARM
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7

可见Ubuntu12的交叉环境是cpuv7(debian armhf),所以arm虚拟机需要是v7的。

若使用debian armel,cpu是v5的,信息如下:

root@debian-armel:~# cat /proc/cpuinfo 
Processor    : ARM926EJ-S rev 5 (v5l)
CPU revision    : 5

若使用debian armhf,cpu是v7的,信息如下:

root@debian-armhf:~# cat /proc/cpuinfo 
Processor    : ARMv7 Processor rev 0 (v7l)
CPU architecture: 7

将测试程序编译后scp到arm虚拟机,可以运行:

root@debian-armhf:~# ./test 
hello, arm!