I have an IPCamera on my LAN streaming video using RTSP. I have been able to capture and display it successfully using ffplay command:
ffplay rtsp://admin:123456@192.168.2.50:7070
(with authentication)
So I would like to achieve the same using programming in C/C++ using ffmpeg
library. I guess this must be possible.
So let me phrase two simple questions :
How do I receive the stream in a C/C++ program using FFMPEG library? (just provide some URL/tutorial, as google was not helpful)
How do I display the received video? (same here, some good URL to direct me).
FWIW, I've updated the code provided by @technique to work with the libraries I have from FFMPEG 3.2.2. Hopefully this helps someone Googling this. There are some small changes that could be confusing for people stumbling upon this answer.
It can be compiled by something to the effect of:
I include the
-w
since there are a lot of deprecation warnings for these functions in the library. You will need to have pkg-config as well as the libavformat and libswscale libraries installed.FFmpeg can open rtsp streams directly just like opening local video files. Here is a tutorial code that updates with the most recent version of FFmpeg.
check your ./configure file. May be its compile for
armlinux
not for thex86
. thats why you are getting undefined reference to'avcodec_register_all'
Here is the solution:-
And after that compile your application.
For rtsp streams the following is working for me (after receiving frames i save the result to a ppm file):