111
cd <你的软件下载目录>
sudo apt-get update
sudo apt-get install libx264-dev
wget http://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2
sudo tar jxvf ffmpeg-4.1.tar.bz2
cd ffmpeg-4.1/
sudo ./configure --prefix=/opt/ffmpeg --enable-shared --enable-pthreads --enable-gpl --enable-avresample --enable-libx264 --disable-yasm
sudo make
sudo install
raspivid -w 640 -h 480 -b 15000000 -t 0 -a 12 -a 1024 -a "CAM-1 %Y-%m-%d %X" -ae 18,0xff,0x808000 -o - | ffmpeg -re -i - -s 640x480 -vcodec copy -acodec copy -b:v 800k -b:a 32k -f flv rtmp://43.143.184.245/videotest
Connection to tcp://43.143.184.245:1935 failed: Connection refused [rtmp @ 0xc40490] Cannot open connection tcp://43.143.184.245:1935 rtmp://43.143.184.245/videotest: Connection refused
ffmpeg -s 720x480 -i /dev/video0 -b:v 2000000 -c:v h264_omx -f flv http://43.143.184.245:8080/live?port=1935&app=myapp&stream=mystream
http://mjvvv.cn/blogBrowse?blogId=58
https://github.com/raspberrypi/firmware/blob/master/opt/vc/lib/libopenmaxil.so
https://github.com/raspberrypi/firmware/blob/master/opt/vc/lib/libbcm_host.so
https://blog.csdn.net/maum61/article/details/121228183
ffmpeg -s 720x480 -i /dev/video0 -b:v 2000000 -c:v h264_omx -f flv rtmp://43.143.184.245:1935/myapp/test
av_interleaved_write_frame(): Network is unreachable
[flv @ 0x1309de0] Failed to update header with correct duration.
[flv @ 0x1309de0] Failed to update header with correct filesize.
Error writing trailer of rtmp://43.143.184.245:1935/hls: Network is unreachable
frame=58433 fps= 20 q=-0.0 Lsize= 57720kB time=00:32:59.90 bitrate= 238.8kbits/s dup=0 drop=21 speed=0.679x
video:56580kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.016050%
Conversion failed!
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-static --disable-shared --prefix=/usr/local --disable-opencl --disable-thumb --disable-pic --disable-stripping --enable-small --enable-ffmpeg --enable-ffplay --enable-ffprobe --disable-doc --disable-htmlpages --disable-podpages --disable-txtpages --disable-manpages --disable-everything --enable-libx264 --enable-encoder=libx264 --enable-decoder=h264 --enable-encoder=aac --enable-decoder=aac --enable-encoder=ac3 --enable-decoder=ac3 --enable-encoder=rawvideo --enable-decoder=rawvideo --enable-encoder=mjpeg --enable-decoder=mjpeg --enable-demuxer=concat --enable-muxer=flv --enable-demuxer=flv --enable-demuxer=live_flv --enable-muxer=hls --enable-muxer=segment --enable-muxer=stream_segment --enable-muxer=mov --enable-demuxer=mov --enable-muxer=mp4 --enable-muxer=mpegts --enable-demuxer=mpegts --enable-demuxer=mpegvideo --enable-muxer=matroska --enable-demuxer=matroska --enable-muxer=wav --enable-demuxer=wav --enable-muxer='pcm' --enable-demuxer='pcm' --enable-muxer=rawvideo --enable-demuxer=rawvideo --enable-muxer=rtsp --enable-demuxer=rtsp --enable-muxer=rtsp --enable-demuxer=sdp --enable-muxer=fifo --enable-muxer=tee --enable-parser=h264 --enable-parser=aac --enable-protocol=file --enable-protocol=tcp --enable-protocol=rtmp --enable-protocol=cache --enable-protocol=pipe --enable-filter=aresample --enable-filter=allyuv --enable-filter=scale --enable-libfreetype --enable-indev=v4l2 --enable-indev=alsa --enable-indev=alsa --enable-outdev=alsa --enable-omx --enable-omx-rpi --enable-encoder=h264_omx --enable-mmal --enable-hwaccel=h264_mmal --enable-decoder=h264_mmal
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
https://www.bbsmax.com/A/x9J2YwOWz6/
https://blog.csdn.net/u011745205/article/details/88619962
https://www.cnblogs.com/hilary0614/p/dht11.html
# -*- coding: utf-8 -*-
import paho.mqtt.client as mqtt
import time
import hashlib
import hmac
import random
import json
#这个就是我们在阿里云注册产品和设备时的三元组啦
#把我们自己对应的三元组填进去即可
options = {
'productKey':'你的productKey',
'deviceName':'你的deviceName',
'deviceSecret':'你的deviceSecret',
'regionId':'cn-shanghai'
}
HOST = options['productKey'] + '.iot-as-mqtt.'+options['regionId']+'.aliyuncs.com'
PORT = 1883
PUB_TOPIC = "/sys/" + options['productKey'] + "/" + options['deviceName'] + "/thing/event/property/post";
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# client.subscribe("the/topic")
# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))
def hmacsha1(key, msg):
return hmac.new(key.encode(), msg.encode(), hashlib.sha1).hexdigest()
def getAliyunIoTClient():
timestamp = str(int(time.time()))
CLIENT_ID = "paho.py|securemode=3,signmethod=hmacsha1,timestamp="+timestamp+"|"
CONTENT_STR_FORMAT = "clientIdpaho.pydeviceName"+options['deviceName']+"productKey"+options['productKey']+"timestamp"+timestamp
# set username/password.
USER_NAME = options['deviceName']+"&"+options['productKey']
PWD = hmacsha1(options['deviceSecret'],CONTENT_STR_FORMAT)
client = mqtt.Client(client_id=CLIENT_ID, clean_session=False)
client.username_pw_set(USER_NAME, PWD)
return client
if __name__ == '__main__':
client = getAliyunIoTClient()
client.on_connect = on_connect
client.on_message = on_message
client.connect(HOST, 1883, 300)
payload_json = {
'id': int(time.time()),
'params': {
'temperature': random.randint(20, 30),#随机温度
'humidity': random.randint(40, 50)#随机相对湿度
},
'method': "thing.event.property.post"
}
print('send data to iot server: ' + str(payload_json))
client.publish(PUB_TOPIC,payload=str(payload_json),qos=1)
client.loop_forever()
https://help.aliyun.com/document_detail/156188.html?spm=a2c4g.156191.0.0.4e104ae4Ji0ZOG
#!/usr/bin/python3
import aliLink,mqttd,rpi
import time,json
import Adafruit_DHT
import RPi.GPIO as GPIO
import sys
#针脚
channel = 21
GPIO.setmode(GPIO.BCM)
#定义针脚为input口
GPIO.setup(channel, GPIO.IN)
# 三元素(iot后台获取)
ProductKey = 'ifjvxH1tX7y'
DeviceName = 'raspi-0001'
DeviceSecret = "98de0b98b70225dcdbb2ed2422f7b20e"
# topic (iot后台获取)
POST = '/sys/ifjvxH1tX7y/raspi-0001/thing/event/property/post' # 上报消息到云
POST_REPLY = '/sys/ifjvxH1tX7y/raspi-0001/thing/event/property/post_reply'
SET = '/sys/ifjvxH1tX7y/raspi-0001/thing/service/property/set' # 订阅云端指令
# 消息回调(云端下发消息的回调函数)
def on_message(client, userdata, msg):
#print(msg.payload)
Msg = json.loads(msg.payload)
#switch = Msg['params']['PowerLed']
#rpi.powerLed(switch)
#print(msg.payload) # 开关值
#连接回调(与阿里云建立链接后的回调函数)
def on_connect(client, userdata, flags, rc):
pass
# 链接信息
Server,ClientId,userNmae,Password = aliLink.linkiot(DeviceName,ProductKey,DeviceSecret)
# mqtt链接
mqtt = mqttd.MQTT(Server,ClientId,userNmae,Password)
mqtt.subscribe(SET) # 订阅服务器下发消息topic
mqtt.begin(on_message,on_connect)
# 信息获取上报,每1秒钟上报一次系统参数
while True:
time.sleep(1)
# 获取传感器信息
humidity, temperature = Adafruit_DHT.read_retry(11, 4)
if GPIO.input(channel) == GPIO.LOW:
isWet = 0
else:
isWet = 1
# 构建与云端模型一致的消息结构
updateMsn = {
'airTemp':temperature,
'airHumidity':humidity,
'isWet':isWet
}
JsonUpdataMsn = aliLink.Alink(updateMsn)
print(JsonUpdataMsn)
mqtt.push(POST,JsonUpdataMsn) # 定时向阿里云IOT推送我们构建好的Alink协议数据