Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VideoWriter out;
- void udp_start_video_writer (void)
- {
- out.open("appsrc ! videoconvert ! x264enc tune=zerolatency byte-stream=true threads=4 ! mpegtsmux ! udpsink host=192.168.1.98 port=1234",
- VideoWriter::fourcc('X','2','6','4'),
- 30.0,
- Size(UDPDATA_FRAME_WIDTH, UDPDATA_FRAME_HEIGHT),
- true);
- }
- int main(){
- // Some initializations...
- while(1) {
- // Create an image to hold initial frame data
- Mat PrScr(UDPDATA_FRAME_WIDTH, UDPDATA_FRAME_HEIGHT, CV_8UC(4));
- // PrScr frame is read here...
- // ....
- // ....
- if(PrScr.size().width!=0 && out.isOpened()) // skip errorneous data
- {
- // Rotate image
- cv::rotate(PrScr, PrScr, cv::ROTATE_180);
- // Change image's color space
- cv::cvtColor(PrScr, PrScr, cv::COLOR_RGB2BGR);
- //Write image to VideoWriter's output (piped through gstreamer)
- out.write(PrScr);
- }
- }
- }
- VideoCapture video_input
- video_input.open("udpsrc port=1234 ! tsparse ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! appsink", cv::CAP_GSTREAMER);
- gst-launch-1.0 udpsrc port=1234 ! tsparse ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! appsink
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement