Decoding h264 (High) stream using OpenCV ffmpeg on Ubuntu

I work with a video stream (without sound) from an ip camera on Ubuntu 14.04. I also start with Ubuntu and everything on it. Everything was great with a camera that has these options (from FFMPEG):

Input #0, rtsp, from 'rtsp://*private*:8900/live.sdp': 0B f=0/0   
  Metadata:
    title           : RTSP server
    Stream #0:0: Video: h264 (Main), yuv420p(progressive), 352x192, 29.97 tbr, 90k tbn, 180k tbc

But then I changed to a newer camera, which has the following options:

Input #0, rtsp, from 'rtsp://*private*/media/video2':0B f=0/0   
  Metadata:
    title           : VCP IPC Realtime stream
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1280x720, 25 fps, 25 tbr, 90k tbn, 50 tbc

My C ++ program uses OpenCV3 to process the stream. By default, OpenCV uses ffmpeg to decode and display the stream using the VideoCapture function.

VideoCapture vc;
vc.open(input_stream);
while ((vc >> frame), !frame.empty()) {
   *do work*
}

With the new camera stream, I get errors like this (from ffmpeg):

[h264 @ 0x7c6980] cabac decode of qscale diff failed at 41 38
[h264 @ 0x7c6980] error while decoding MB 41 38, bytestream (3572)
[h264 @ 0x7c6980] left block unavailable for requested intra mode at 0 44
[h264 @ 0x7c6980] error while decoding MB 0 44, bytestream (4933)
[h264 @ 0x7bc2c0] SEI type 25 truncated at 208
[h264 @ 0x7bfaa0] SEI type 25 truncated at 206
[h264 @ 0x7c6980] left block unavailable for requested intra mode at 0 18
[h264 @ 0x7c6980] error while decoding MB 0 18, bytestream (14717)

Sometimes the image breaks down, sometimes it completely freezes. After a few seconds to several minutes, the stream is completely frozen without errors. However, he plays perfectly on vlc. I installed the latest version (3.2.2) of ffmpeg player with

./configure --enable-gpl --enable-libx264

, ffplay ( OpenCV VideoCapture), , , :

[NULL @ 0x7f834c008c00] SEI type 25 size 896 truncated at 320=1/1   
[h264 @ 0x7f834c0d5d20] SEI type 25 size 896 truncated at 319=1/1   
[rtsp @ 0x7f834c0008c0] max delay reached. need to consume packet   
[rtsp @ 0x7f834c0008c0] RTP: missed 1 packets
[h264 @ 0x7f834c094740] concealing 675 DC, 675 AC, 675 MV errors in P frame
[NULL @ 0x7f834c008c00] SEI type 25 size 896 truncated at 320=1/1  

. h265 mjpeg. mjpeg 5 , . , . - API-, VideoCapture. , - ? , :

  • - OpenCV ffmpeg , libx264

  • - OpenCV libVlc ffmpeg

vlc , , , , . , , parsing ? , - , , , Ubuntu.

  • vlc , .

, , , .
.

+4
2

.

  • OpenCV ffmpeg, , .
  • VLC > , , , .
  • . .
  • , , -

    [NULL @0x7f834c008c00] SEI 25 896, 320 = 1/1
    [h264 @0x7f834c0d5d20] SEI 25 896, 319 = 1/1

. , - , . , , .

+1

, RTP. , .

?tcp , . rtsp://*private*/media/video2?tcp OpenCV open TCP, , / .

0

Source: https://habr.com/ru/post/1664449/


All Articles