FFMPEG to send RTSP encoded stream C++(FFMPEG 发送 RTSP 编码流 C++)
问题描述
我试图找出一种方法来获取我在 FFMEG 中创建的编码 H264 图像,并使用 FFMPEG 通过 RTSP 将其发送出去,是否有一些示例代码或教程可以展示如何执行此操作.我试着在网上搜索,但我找不到任何东西.
I am trying to figure out a way to take an encoded H264 image that I have created in FFMEG and send it out via RTSP using FFMPEG, is there some sample code or a tutorial out there that shows how to do this. I tried searching the web, but there is nothing that I could find out there.
非常感谢任何帮助.提前致谢.
Any help is greatly appreciated. Thanks in advance.
推荐答案
我在 docs/examples/muxing.c 中做了一些改动,这里是我使用 mpeg4 rtsp 传输音频和视频流的代码
I made few changes in docs/examples/muxing.c here is my code which transmits audio and video streams using mpeg4 rtsp
#include <stdio.h>
#include <vector>
#include <windows.h>
#include <iostream>
#include <fstream>
#include <time.h>
#define _XOPEN_SOURCE 600 /* for usleep */
extern "C"
{
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
#include <libavcodecavcodec.h>
#include <libavutil/imgutils.h>
#include <libavutil/samplefmt.h>
//#include <libavutil/timestamp.h>
#include <libswscaleswscale.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfiltergraph.h>
#include <libavfilter/avcodec.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include <libavutil/opt.h>
#include <libavutil/imgutils.h>
#include <libavutil/mathematics.h>
#include <libavutil/samplefmt.h>
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <math.h>
#include <libavutil/opt.h>
#include <libavcodec/avcodec.h>
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <libavutil/imgutils.h>
#include <libavutil/mathematics.h>
#include <libavutil/samplefmt.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfiltergraph.h>
#include <libavfilter/avcodec.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include <libavutil/opt.h>
#include <libavutil/opt.h>
#include <libavutil/mathematics.h>
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>
}
using namespace std;
#pragma comment(lib, "dev\avcodec.lib")
#pragma comment(lib, "dev\avformat.lib")
#pragma comment(lib, "dev\avfilter.lib")
//#pragma comment(lib, "dev\avcodec.lib")
#pragma comment(lib, "dev\avdevice.lib")
//#pragma comment(lib, "dev\avfilter.lib")
//#pragma comment(lib, "dev\avformat.lib")
#pragma comment(lib, "dev\avutil.lib")
#pragma comment(lib, "dev\postproc.lib")
#pragma comment(lib, "dev\swresample.lib")
#pragma comment(lib, "dev\swscale.lib")
#ifdef _MSC_VER
//#define snprintf c99_snprintf
//inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
//{
// int count = -1;
//
// if (size != 0)
// count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
// if (count == -1)
// count = _vscprintf(format, ap);
//
// return count;
/
本文标题为:FFMPEG 发送 RTSP 编码流 C++


- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 静态初始化顺序失败 2022-01-01
- C++ 协变模板 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- STL 中有 dereference_iterator 吗? 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 从python回调到c++的选项 2022-11-16
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01