Ask Your Question

Revision history [back]

How do i use videowriter with ffmpeg for streaming?

Documentation at https://docs.opencv.org/master/d0/da7/videoio_overview.html states, that "OpenCV can use the FFmpeg library (http://ffmpeg.org/) as backend to record, convert and stream audio and video".

I wonder how can i use ffmpeg as backend to stream video? for example i have ffmpeg command that works if i pipe cv::Mat from program stdout to ffmpeg stdin

myprogram.exe | ffmpeg -f rawvideo -pixel_format bgr24 -video_size 640x480 -framerate 30 -i - -vcodec libx264 -tune zerolatency -b 6000k -f mpegts udp://127.0.0.1:5000

so how can i shortcut it and have same pipe inside myprogram? for example for CAP_GSTREAMER one can write gstreamer pipe in videowriter cv::Videowriter writer; writer.open("appsrc ! etc...", cv::CAP_GSTREAMER, fourcc, fps, size);