当前位置:网站首页>Raspberry pie RTMP streaming local camera image
Raspberry pie RTMP streaming local camera image
2022-07-27 05:12:00 【Suyuoa】
Catalog
1. install ffmpeg
Input sudo apt-get install ffmpeg omxplayer

If the following error is displayed

You need to do it again sudo apt-get update

Then type... Again sudo apt-get install ffmpeg omxplayer

After successful installation , You can enter ffmpeg To view the , My current ffmpeg Version is 3.2.15

2. install srs
srs You can deploy on other servers , It can also be deployed directly on raspberry pie ,srs Project address GitHub - ossrs/srs: SRS is a simple, high efficiency and realtime video server, supports RTMP, WebRTC, HLS, HTTP-FLV and SRT.
Input after decompression
cd ./srs-3.0release/trunk
./configure && make
After execution, it will be compiled , The compilation process will output many things , The first part is already crowded , I intercepted the image that was successfully compiled

The default port is 1935, If you want to change the port, you can enter vim ./conf/srs.conf Make changes
![]()
I haven't made any changes here

After input ./objs/srs -c conf/srs.conf

Then type sudo iptables -I INPUT -p tcp --dport 1935 -j ACCEPT
- there 1935 It should be consistent with the port above you
![]()
3. Push flow
use python Written , need opencv, Other libraries do not need ,IP Just use raspberry pie locally IP( If your srs Put it elsewhere and use srs Of the device IP), The port is also srs The port of , hinder /live/test You can customize
import cv2
import subprocess as sp
cam = cv2.VideoCapture(0)
img_counter = 0
ret, frame = cam.read()
WIDTH = frame.shape[1]
HEIGHT = frame.shape[0]
RTMP_URL = 'rtmp://192.168.33.68:1935/live/test'
FPS = 24
def ffpemgtortmp(width, height, recivedrtmp_addr, fps):
print(recivedrtmp_addr)
command = ['ffmpeg',
'-y',
'-f', 'rawvideo',
'-vcodec', 'rawvideo',
'-pix_fmt', 'bgr24',
'-s', "{}x{}".format(width, height),
'-r', str(fps),
'-i', '-',
'-c:v', 'libx264',
'-pix_fmt', 'yuv420p',
'-preset', 'ultrafast',
'-f', 'flv',
recivedrtmp_addr]
print('command', command)
p = sp.Popen(command, stdin=sp.PIPE)
return p
def main():
p = ffpemgtortmp(WIDTH, HEIGHT, RTMP_URL, FPS)
while cam.isOpened():
ret, frame = cam.read()
p.stdin.write(frame.tostring())
print('send frame')
if __name__ == '__main__':
main()If it's always there send frame It means that streaming is successful

4. receive
- The receiving end should be under the same intranet as raspberry pie
I am here windows use VLC The player receives

Click the media in the upper left corner , Open Network Stream

Enter the address pushed in raspberry pie , Then click play

After a while, the image of your camera will appear

There will be a delay , But no card , I don't know if it's two devices wifi The reason for communication
边栏推荐
- Quoted popular explanation
- Solution and principle analysis of feign call missing request header
- The execution process of a select statement in MySQL
- MySQL storage engine and its differences
- 35.滚动 scroll
- Detailed description of binary search tree
- Invert a Binary Tree
- Use of file i/o in C
- 知识点总结(一)
- [error reporting] cannot read property 'parsecomponent' of undefined
猜你喜欢

Knapsack problem DP

JVM上篇:内存与垃圾回收篇八--运行时数据区-方法区
![[error reporting] cannot read property 'parsecomponent' of undefined](/img/54/8d4225ec596d6b78348b181a3e636f.png)
[error reporting] cannot read property 'parsecomponent' of undefined

集合框架的使用
![[error reporting]: cannot read properties of undefined (reading 'prototype')](/img/e4/528480610b9eed6028d7b3b87571e2.png)
[error reporting]: cannot read properties of undefined (reading 'prototype')

What if Photoshop prompts that the temporary storage disk is full? How to solve the problem that PS temporary storage disk is full?

How do I reset Photoshop preferences? PS method of resetting preferences

Advantages of smart exhibition hall design and applicable industry analysis

再一个技巧,每月稳赚3万+

老子云携手福昕鲲鹏,首次实现3D OFD三维版式文档的重大突破
随机推荐
Final Cut Pro Chinese tutorial (1) basic understanding of Final Cut Pro
Complete Binary Tree
There is no need to install CUDA and cudnn manually. You can install tensorflow GPU through a one-line program. Take tensorflow gpu2.0.0, cuda10.0, cudnn7.6.5 as examples
The execution process of a select statement in MySQL
Customize the viewport height, and use scrolling for extra parts
Solution and principle analysis of feign call missing request header
Laozi cloud and Fuxin Kunpeng achieved a major breakthrough in 3D ofd 3D format documents for the first time
Invert a Binary Tree
《Robust and Precise Vehicle Localization based on Multi-sensor Fusionin Diverse City Scenes》翻译
Summary of knowledge points (I)
写代码涉及到的斜杠/和反斜杠\
Introduction to MySQL optimization
34. 分析flexible.js
树莓派rtmp推流本地摄像头图像
二维数组求和 练习
使用ngrok做内网穿透
File processing (IO)
JVM Part 1: memory and garbage collection part 14 -- garbage collector
MySQL download and installation & perfect uninstall
动态内存函数的介绍(malloc free calloc realloc)