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++


基础教程推荐
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- Windows Media Foundation 录制音频 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01