Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. VideoWriter out;
  2.  
  3. void udp_start_video_writer (void)
  4. {
  5. out.open("appsrc ! videoconvert ! x264enc tune=zerolatency byte-stream=true threads=4 ! mpegtsmux ! udpsink host=192.168.1.98 port=1234",
  6. VideoWriter::fourcc('X','2','6','4'),
  7. 30.0,
  8. Size(UDPDATA_FRAME_WIDTH, UDPDATA_FRAME_HEIGHT),
  9. true);
  10. }
  11.  
  12. int main(){
  13. // Some initializations...
  14. while(1) {
  15. // Create an image to hold initial frame data
  16. Mat PrScr(UDPDATA_FRAME_WIDTH, UDPDATA_FRAME_HEIGHT, CV_8UC(4));
  17.  
  18. // PrScr frame is read here...
  19. // ....
  20. // ....
  21.  
  22. if(PrScr.size().width!=0 && out.isOpened()) // skip errorneous data
  23. {
  24. // Rotate image
  25. cv::rotate(PrScr, PrScr, cv::ROTATE_180);
  26.  
  27. // Change image's color space
  28. cv::cvtColor(PrScr, PrScr, cv::COLOR_RGB2BGR);
  29.  
  30. //Write image to VideoWriter's output (piped through gstreamer)
  31. out.write(PrScr);
  32. }
  33. }
  34. }
  35.  
  36. VideoCapture video_input
  37. video_input.open("udpsrc port=1234 ! tsparse ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! appsink", cv::CAP_GSTREAMER);
  38.  
  39. gst-launch-1.0 udpsrc port=1234 ! tsparse ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! appsink
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement