I have a camera which rotates 180° per second, returns a picture for every 3° of rotation and loops, the resolution of a single image is 640×512.
Now, I process the image using OpenCV
and get a panorama image. The resolution of the image is close to 35000×512(so do the cv::Mat
) and one is generated per second. Now, I need to establish an RTSP stream to push the panorama image in real time with 1fps.
I use C++ , ffmpeg
and mediamtx
for this work and encountered some tough problems.
①first I tried cv::imencode()
to encode cv::Mat
into jpeg
format and stream it with the encoder AV_CODEC_ID_MJPEG
, it works on images smaller than 2048×512, but failed on larger images. This is my test image, a BGR-repeat strip.
The stream works fine in low resolution but failed in high resolution. The following picture is the result of rtsp stream read by VLC. I set the resolution to 8000×512 but VLC displays it as 2040×512.
②Then I mentioned H265 encoder AV_CODEC_ID_HEVC
, found it supports 8192×8192 images. But the debug log of ffmpeg repeats NAL 200k > 1420
warning, mediamtx
warns loss of RTP packets, and no rtsp stream shown.
③I tried fifo file of linux to create rtsp stream ,write encoded jpeg data into std::tmpfile()
and let ffmpeg read, split the panorama image, encode separately and combine them into one AVPacket
, none of them works.
What should I do to get my goal?