cyfile / Matlab-miscellanies

各种Matlab代码
0 stars 0 forks source link

用 ipcam 对接 ffmpeg 提供的桌面流 #13

Open 213cy opened 4 years ago

213cy commented 4 years ago

ipcam 是 MATLAB Support Package for IP Cameras (MATLAB Add-on附加功能)提供的一个命令

先在电脑端 下载ffmpeg 并添加到cmd 里.

然后用其抓取桌面 并按摄像头格式​​​推流​

matlab 命令里用 ipcam 接收

213cy commented 4 years ago

%% %% 抓屏推流
%%
ffmpeg -f gdigrab -framerate 6 -i desktop -c:v libx264rgb -crf 0 -preset ultrafast output.mkv
ffmpeg -f gdigrab -framerate 6 -i desktop -c:v libx264rgb -qp 0 -preset ultrafast output.mkv

%% http 完美对接 matlab ipcam
ffmpeg -i a.mp4 -listen 1 http://127.0.0.1:8000/video.mjpeg
ffmpeg -f gdigrab -framerate 3 -i desktop -vf "scale=iw/2:ih/2" -listen 1 http://127.0.0.1:8000/video.mjpeg
ffplay http://127.0.0.1:8000/video.mjpeg

%% rtsp 先要开始客户端监听 再推流(先运行 ffplay 再运行 ffmpeg)
ffmpeg -i a.mp4 -f rtsp -rtsp_transport tcp rtsp://localhost:8888/live.sdp
ffplay -rtsp_flags listen rtsp://localhost:8888/live.sdp?tcp

ffmpeg -f gdigrab -framerate 3 -i desktop -f rtsp rtsp://localhost:8888/live.sdp
ffplay -rtsp_flags listen rtsp://localhost:8888/live.sdp

ffmpeg -f gdigrab -framerate 6 -i desktop -c:v libx264rgb -preset ultrafast -f rtsp  rtsp://127.0.0.1:3000/live.sdp
ffplay -rtsp_flags listen rtsp://127.0.0.1:3000/live.sdp

ffmpeg -f gdigrab -framerate 3 -i desktop -vf "scale=iw/2:ih/2" -f rtsp rtsp://localhost:8888/live.sdp
ffplay -rtsp_flags listen rtsp://localhost:8888/live.sdp

%% image
ffmpeg -f gdigrab -i desktop -frames:v 1 -vf "scale=iw/2:ih/2" a.jpeg
213cy commented 4 years ago
cam = ipcam('rtsp://127.0.0.1:8554/a')
cam = ipcam('http://127.0.0.1:8000/video.mjpeg')
preview(cam)
closePreview(cam)
img = snapshot(cam);
imshow(img)
clear cam
213cy commented 4 years ago

https://github.com/cyfile/Matlab-base-toolbox/issues/21