ffmpeg解封装rtsp并录制视频-(2)使用VLC模拟一个rtsp服务器并用ffmpeg解封装该rtsp流

VCL模拟服务器并打开播放该视频文件:

- 准备好一个mp4文件,打开vlc软件
    - 选择“媒体”=》“流”
    - 添加一个mp4文件
    - 点击下方按钮选择“串流”
    - 下一步目标选择rtsp 点击“添加”
    - 端口默认8554
    - 路径设置 /test
    - 用另一个vlc打开串流播放
    - rtsp://127.0.0.1:8554/test

在VCL播放的同时用代码解封装该rtsp文件:

在上一篇的主函数中:

#include <iostream>
#include <thread>
#include "xtools.h"
#include "xdemux_task.h"
using namespace std;
//class TestThread :public XThread
//{
//public:
//    void Main()
//    {
//        LOGDEBUG("TestThread Main begin");
//        while (!is_exit_)
//        {
//            this_thread::sleep_for(1ms);
//        }
//        LOGDEBUG("TestThread Main end");
//    }
//};
#define CAM1 \
"rtsp://admin:admin@192.168.2.108/cam/realmonitor?channel=1&subtype=0"
#define MP4 "v1080.mp4"
#define CAM2 \
"rtsp://127.0.0.1:8554/test"
int main(int argc, char* argv[])
{
    XDemuxTask det;
    for (;;)//保证第一次连接就失败的情况
    {
        if (det.Open(CAM2))
        {
            break;
        }
        MSleep(100);
        continue;
    }

    det.Start();
    //TestThread tt;
    //tt.Start();
    //this_thread::sleep_for(3s);
    //tt.Stop();
    getchar();
    return 0;
}

运行结果 :

一个VCL模拟服务器,一个VCL播放该流,用代码进行解封装成功

最近更新

  1. TCP协议是安全的吗?

    2024-06-17 00:24:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-17 00:24:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-17 00:24:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-17 00:24:03       18 阅读

热门阅读

  1. 力扣爆刷第149天之TOP100五连刷(LRU、K个一组)

    2024-06-17 00:24:03       6 阅读
  2. python嵌套指南

    2024-06-17 00:24:03       8 阅读
  3. CAPL如何在底层模拟TCP Client端断开TCP连接

    2024-06-17 00:24:03       6 阅读
  4. 杀戮尖塔游戏

    2024-06-17 00:24:03       10 阅读
  5. Elasticsearch聚合分析:数据汇总与可视化的奥秘

    2024-06-17 00:24:03       10 阅读
  6. Spring Boot顶层接口实现类注入项目的方法

    2024-06-17 00:24:03       10 阅读