FFMPEG 发送 RTSP 编码流 C++

FFMPEG to send RTSP encoded stream C++(FFMPEG 发送 RTSP 编码流 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++

基础教程推荐