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


基础教程推荐
- 这个宏可以转换成函数吗? 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何检查GTK+3.0中的小部件类型? 2022-11-30