文章目录
- 前言
- [1. 安装rtsp服务器](#1. 安装rtsp服务器)
- [2. 用ffmpeg推送视频到rtsp](#2. 用ffmpeg推送视频到rtsp)
- [3.用VLC 承接播放,查看效果:](#3.用VLC 承接播放,查看效果:)
- [4. 找一个测试集图片集,生成视频](#4. 找一个测试集图片集,生成视频)
前言
要测试盒子上的算法精度,但盒子的算法只能输入rtsp流,这样我们难道只能去摄像头底下演示效果,这样的限制太大了。
解决方案:
1.将测试集图片组成视频
2.将视频生成rtsp流
3.将rtsp流推到算法侧即可
1. 安装rtsp服务器
ref:https://github.com/bluenviron/mediamtx/releases
ref:https://github.com/bluenviron/mediamtx#standalone-binary
然后解压后,运行
./mediamtx
bash
(base) [jianming_ge@localhost software]$ ./mediamtx
2023/08/18 09:53:06 INF MediaMTX v1.0.0
2023/08/18 09:53:06 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2023/08/18 09:53:06 INF [RTMP] listener opened on :1935
2023/08/18 09:53:06 INF [HLS] listener opened on :8888
2023/08/18 09:53:06 INF [WebRTC] listener opened on :8889 (HTTP)
2023/08/18 09:53:06 INF [SRT] listener opened on :8890 (UDP)
可以看到,RTSP那一行,TCP的8554端口
2. 用ffmpeg推送视频到rtsp
使用命令:
ffmpeg -re -i test_person.mp4 -c copy -f rtsp rtsp://172.18.42.16:8554/a
输出:
bash
(base) [jianming_ge@localhost test_video]$ ffmpeg -re -i test_person.mp4 -c copy -f rtsp rtsp://172.18.42.16:8554/a
ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7.3.0 (crosstool-NG 1.23.0.449-a04d0)
configuration: --prefix=/home/miniconda_root --cc=/opt/conda/conda-bld/ffmpeg_1597178665428/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-pic --enable-pthreads --enable-shared --disable-static --enable-version3 --enable-zlib --enable-libmp3lame
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_person.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2020-03-04T03:26:20.000000Z
Duration: 00:00:14.77, start: 0.000000, bitrate: 3989 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 3988 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2020-03-04T04:05:36.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Output #0, rtsp, to 'rtsp://172.18.42.16:8554/a':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
encoder : Lavf58.45.100
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 3988 kb/s, 30 fps, 30 tbr, 90k tbn, 30 tbc (default)
Metadata:
creation_time : 2020-03-04T04:05:36.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 443 fps= 30 q=-1.0 Lsize=N/A time=00:00:14.73 bitrate=N/A speed= 1x
3.用VLC 承接播放,查看效果:
成功。