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

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

  • 准备好一个mp4文件,打开vlc软件

  • 选择"媒体"=》"流"

  • 添加一个mp4文件

  • 点击下方按钮选择"串流"

  • 下一步目标选择rtsp 点击"添加"

  • 端口默认8554

  • 路径设置 /test

  • 用另一个vlc打开串流播放

  • rtsp://127.0.0.1:8554/test

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

在上一篇的主函数中:

cpp 复制代码
#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播放该流,用代码进行解封装成功

相关推荐
合尘猫2 分钟前
用 6GB 显卡搭短视频产线:MiniMax H3 + ffmpeg 全流程实录(55 秒片 / 40 分钟)
人工智能·音视频
JonaHu1 小时前
博客转视频总返工?用章节清单、样片和 FFmpeg 搭一条可控流水线
ffmpeg·ai视频·内容创作·acedatacloud
the3clipse2 天前
Windows 11 26H2 声音与音频问题排查指南:没声音、麦克风不收音与蓝牙音频优化
音视频·le audio·windows 11 26h2·win11没声音·麦克风没声音·蓝牙耳机音质·音频服务修复
开开心心就好2 天前
PDF水印怎么去掉?勾选对象再点匹配
java·前端·mysql·支持向量机·pdf·音视频·模拟退火算法
RobinDevNotes3 天前
Claude Code 剪视频,不上传、不要 API Key
人工智能·python·音视频·开发工具·ipython
伯奥克客服3 天前
2026年视频综合一体机架构选型:从接口协议到流媒体底层的深度技术解析
架构·音视频
开开心心就好3 天前
两张表格数据对比工具,不用写函数也能查
算法·spring·智能手机·pdf·电脑·intellij-idea·音视频
FansAI_art3 天前
多角色 AIGC 短片的双模型分工:静态生图与图生视频怎么接
aigc·音视频
山顶夕景4 天前
【ECCV2026】流式视频理解Thinking in Streaming Video
音视频·vlm·视频理解·多模态理解·流式视频
StarsGreen5 天前
ffmpeg中常用结构体以及函数简介以及版本变化情况
ffmpeg