Reputation: 3713
I'm using FFMPEG with C++ to read frames and decode them from RTSP Stream on IP Camera.
Anything is ok, but while decoding, I try to change stream resolution config on IP Camera (ex: change from 1280x720 to 1920x1080).
The result is av_read_frame()
in while loop still read successful next frames (with new resolution) without error. So I can not detect that change to reinit buffer or reconnect stream to update other stream's information.
av_read_frame()
will read an AVPacket, If I can read resolution info in the AVPacket, then I can detect that change and reinit buffer. But I can't see any resolution info in AVPacket struct.
How do I detect a resolution change while reading and decoding the stream?
I'm using many codecs as H264 and H265/H265+. This case happened with all 3 codecs above.
In many cases, I also store the AVPacket for later playback, so there's no need for decode. I need to detect the resolution change immediately to be able to properly build header information to store on the HDD.
Upvotes: 1
Views: 1012
Reputation: 3713
Use av_parser_parse2()
to parse information such as Resolution
from AVPacket
, and compare it to the old values, to detect the change and then reconnect it again.
Upvotes: 0
Reputation: 31120
In band resolution changes can not be detected by av_read_frame()
because av_read_frame()
does not parse the frame, It only reads the data from the stream and places it into a buffer. You will need to use a bitstreram parser, or send the frame to the decoder (if the decoder supports resolution changes). Every codec is different however, so I cant give you more information unless I know what codec you are using.
Upvotes: 2