Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
140 views
in Technique[技术] by (71.8m points)

How to grab a single image from a video stream without connecting the stream (bandwidth issue)

Not sure it is possible, but how can I get a single Image from video stream WITHOUT connecting the stream (rtsp) itself (I have bandwidth issue)?

(priority to python but any code framework/language will be good).

This is an example SDP file of the stream:

v=0
o=Teleste 11501847 688 IN IP4 1.1.1.1
s=unnamed (mpeg4/tx-1)
i=Teleste MP-X AUDIO/VIDEO Encoder
c=IN IP4 221.1.1.1/64
t=0 0
m=video 4002 RTP/AVP 96
b=AS:6400
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=1;config=000001B005000001B509000001000000012000C4F84048800F516843C1463F

I have a solution for extract a single image after establish a connection to the stream, but I'm looking for a solution that will not require a full connection to the stream because of the bandwidth issue.

I'm new with the video streaming world and any idea or suggestion will be good.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Unless your server supports some functionality to provide this, I don't think you can get something from the stream without connecting to the stream.

You presumably already have some solution which will connect, get a frame, and then disconnect, I am guessing. In case you are not aware you can also do this via ffmpeg with the following command, although I am not sure what the bandwidth overhead is or how it opens and closes the connection under the covers - you would need to experiment with it to see:

ffmpeg -y -i rtsp://your_rtsp_strea -frames:v 1 output.jpg

Its worth noting that the codec in use will affect the number of frames you need - simple codecs or codec profiles will encode each frame separately, but others will have reference frames every, for example, 10th frame and the frames in-between will be encoded as a delta to the reference frames. Hence, you need to actually get the previous and sometimes even the next reference frame in addition to your target frame to actually extract the image.

If your stream is available in DASH or HLS, then you also have the option to just download a single segment - these protocols will already have broken the video stream into multiple segments, typically somewhere between 2 and 10 seconds long. However, you do need to make sure you download the segment from the bitrate that you need - these protocols will have multiple bit rates streams to allow for different resolutions and network conditions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...