ffmpeg opencv 指定_如何发送opencv视频到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.

解决方案

Same question ... same answer...

I hope this answer will help you.

In this program I make a screen copy(RGB data) at 20 fps and send image to ffmpeg. i don't use pipe but socket. I use this command line :

ffmpeg -f rawvideo -pixel_format rgb24 -video_size 640x480 -i "tcp://127.0.0.1:2345" -codec:v libx264 -pix_fmt yuv420p Video.mp4

to run ffmpeg and then send data to port 2345 using socket

sock->Write(b.GetData(), nb);

I don't encode frame it is raw data

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值