0
opencvで処理した後に2つのウェブカメラから撮影したビデオストリームをアンドロイドアプリにストリーム配信しようとしています。ビデオRTSPを使用してOpencvから処理した後にPCからAndroidにストリーミング
ここでは、RTSPを使用してopencvからAndroidにビデオストリームを送信しようとしています(gstreamerパイプラインを使用)。
しかし、.sdpファイルの設定をクライアントに送信する方法(ファイル名はlive.sdp)に固執しています。これまでに使用していたコードはここにあります。
//basic
#include <iostream>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
//opencv libraries
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
int main(int argc,char **argv){
Mat im1;
Mat im2;
VideoCapture cap1(1);
VideoCapture cap2(2);
VideoWriter video;
video.open("appsrc ! videoconvert ! x264enc noise-reduction=10000 tune=zerolatency byte-stream=true threads=4 ! mpegtsmux ! rtpmp2tpay send-config=true config-interval=10 pt=96 ! udpsink host=localhost port=5000 -v"
, 0, (double)20,Size(1280, 480), true);
if(video.isOpened()){
cout << "Video Writer is opened!"<<endl;
}else{
cout << "Video Writer is Closed!"<<endl;
return -1;
}
while(1){
cap1.grab();
cap2.grab();
bool bSuccess1 = cap1.read(im2);
bool bSuccess2 = cap2.read(im1);
Size sz1 = im1.size();
Size sz2 = im2.size();
Mat im3(sz1.height, sz1.width+sz2.width, CV_8UC3);
Mat left(im3, Rect(0, 0, sz1.width, sz1.height));
im1.copyTo(left);
Mat right(im3, Rect(sz1.width, 0, sz2.width, sz2.height));
im2.copyTo(right);
video << im3;
//imshow("im3", im3);
if(waitKey(10) == 27){
break;
}
}
cap1.release();
cap2.release();
video.release();
return 0;
}
そして.sdpというファイル構成、
v=0
m=video 5000 RTP/AVP 96
c=IN IP4 localhost
a=rtpmap:96 MP2T/90000
私は、ローカルフォルダ内のVLCからのストリームを再生することができます が
vlc live.sdp
を使用してではなく、ネットワーク内の、使用して、
vlc rtsp://localhost:5000/live.sdp