How to send opencv video's to ffmpeg
I m trying to send the processed opencv Mat as video to ffmpeg. I m encoding the frame and writing it to std output and then piping it to ffmpeg. Here is my code.
C++:
if(!cap.isOpened()) {
cout << "Video not accessible" << endl;
return -1;
} else {
cout << "Video is accessible" << endl;
}
while (true) {
cap >> frame;
//some processing
cv::imencode(".jpg", frame, buff);
for (i = buff.begin(); i != buff.end(); ++i)
std::cout << *i ;
}
My input video resolution is 640x418. I do not alter the video size
After building, I use following command to execute.
./a.out | ffmpeg -f rawvideo -pix_fmt bgr24 -s 640x418 -r 30 -i - -an -f mpegts udp://0.0.0.0:8182
and also this
./a.out | ffmpeg -i pipe:0 -f rawvideo -pix_fmt bgr24 -s 640x418 -r 30 -i - -an -f mpegts udp://0.0.0.0:8182
However none of this seems to work.
Kindly help.