In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge points about how C++ uses ffmpeg to achieve rtsp streaming. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
C++ uses ffmpeg to realize rtsp stream fetching
Flyfish
Environment
Ubuntu 18.04
Qt 5.14.2
FFmpeg-n5.0.1
download
Choose version n5.0.1 here.
Installation and compilation depends on sudo apt-get install nasm configuration
Generation includes static and dynamic libraries
Header files and libraries are in the current install folder
FFmpeg-n5.0.1 $. / configure-- prefix= ". / install"-- enable-shared
Re-execution
Makemake install
Include in the install folder
Lib in the install folder
Ffmepg uses rtsp to fetch flow chart
CMakeLists.txt writing method cmake_minimum_required (VERSION 3.5) project (rtsp LANGUAGES CXX) set (CMAKE_INCLUDE_CURRENT_DIR ON) set (CMAKE_AUTOUIC ON) set (CMAKE_AUTOMOC ON) set (CMAKE_AUTORCC ON) set (CMAKE_CXX_STANDARD 11) set (CMAKE_CXX_STANDARD_REQUIRED ON) find_package (Qt5Core) set (FFMPEG_PREFIX_PATH / path/to/FFmpeg-n5.0.1/install) include_directories (${FFMPEG_PREFIX_PATH} / include /) link_directories (${FFMPEG_PREFIX_PATH} / lib/) add_executable (rtsp main.cpptarget_link_libraries (rtsp avcodec avformat avfilter avutil swresample swscale swscale) implementation code # include extern "C" {# include "libavcodec/avcodec.h" # include "libavformat/avformat.h" # include "libavutil/avutil.h"} int main (int argc) Char * argv []) {int status_error_=-1 Std::string videourl= "rtsp://admin:Admin12345@192.168.3.64:554/Streaming/Channels/1"; AVFormatContext * pFormatCtx = NULL; AVDictionary * options = NULL; AVPacket * av_packet = NULL; / / AVPacket temporarily stores the media data before decoding avformat_network_init (); / / performs global initialization of the network library. / / this function is only used to solve thread safety problems with older GNUTLS or OpenSSL libraries. / / once support for older GNUTLS and OpenSSL libraries is removed, this function will be deprecated and will no longer be of any use. Av_dict_set (& options, "buffer_size", "4096000", 0); / set cache size av_dict_set (& options, "rtsp_transport", "tcp", 0); / / Open it as tcp, av_dict_set (& options, "stimeout", "5000000", 0) / / set timeout disconnection time, in us, 5s av_dict_set (& options, "max_delay", "500000", 0); / / set maximum delay pFormatCtx = avformat_alloc_context () / / used to apply for AVFormatContext type variables and initialize default parameters. The requested space / / opens the network stream or file stream if (avformat_open_input (& pFormatCtx, videourl.c_str (), NULL, & options)! = 0) {std::cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.