当前位置: 首页 > news >正文

FFmpeg 4.3 H265 二十二.3,avformat_open_input 支持打开的协议

avformat_open_input  函数说明:

解封装:avformat_open_input,avformat_find_stream_info,av_read_frame,av_dump_format,avformat_close_input-CSDN博客

原型
/**
 * Open an input stream and read the header. The codecs are not opened.
 * The stream must be closed with avformat_close_input().
 *
 * @param ps       Pointer to user-supplied AVFormatContext (allocated by
 *                 avformat_alloc_context). May be a pointer to NULL, in
 *                 which case an AVFormatContext is allocated by this
 *                 function and written into ps.
 *                 Note that a user-supplied AVFormatContext will be freed
 *                 on failure.
 * @param url      URL of the stream to open.
 * @param fmt      If non-NULL, this parameter forces a specific input format.
 *                 Otherwise the format is autodetected.
 * @param options  A dictionary filled with AVFormatContext and demuxer-private
 *                 options.
 *                 On return this parameter will be destroyed and replaced with
 *                 a dict containing options that were not found. May be NULL.
 *
 * @return 0 on success, a negative AVERROR on failure.
 *
 * @note If you want to use custom IO, preallocate the format context and set its pb field.
 */
int avformat_open_input(AVFormatContext **ps, const char *url,
                        const AVInputFormat *fmt, AVDictionary **options);

avformat_open_input 支持的协议--对url参数的说明

avformat_open_input 支持多种协议,主要通过 FFmpeg 的协议层实现统一访问。以下是主要协议类型及特性:

一、本地文件协议

  • 文件系统协议‌:支持 file:// 前缀或直接路径(如 /home/video.mp4),可处理 MP4、AVI、FLV 等封装格式13
  • 特殊设备‌:如 /dev/video0 摄像头采集设备(需系统支持)3

二、网络流媒体协议

  1. RTSP/RTP

    • 支持 rtsp:// 开头的实时流传输,可通过 rtsp_transport 参数指定 TCP/UDP 传输方式
    • 典型应用:监控摄像头、直播推流
  2. HTTP/HTTPS

    • 支持点播(如 http://example.com/video.m3u8)和直播流(HLS/DASH)
    • 需注意:部分 HTTPS 需配置 SSL 证书
  3. UDP/TCP

    • 原始流传输协议(如 udp://@239.255.0.1:1234),常用于组播场景
  4. 其他专用协议

    • RTMP:rtmp:// 常用于直播推拉流
    • SRT:srt:// 低延迟传输协议

三、特殊协议

  • 管道协议‌:pipe: 支持标准输入输出重定向3
  • 内存协议‌:mem: 直接读写内存数据(需配合自定义 AVIOContext)

四、协议支持验证

若遇到 Protocol not found 错误,需检查:

  1. FFmpeg 编译时是否包含对应协议模块(如 --enable-protocol=rtsp
  2. URL 格式是否符合规范(如遗漏 :// 前缀)
  3. 网络权限或防火墙限制

完整协议列表可通过 ffmpeg -protocols 命令查看。实际使用建议通过 av_dict_set 设置超时等参数优化稳定性。

http://www.xdnf.cn/news/661483.html

相关文章:

  • 07-多线程案例-任务调度
  • NoteGen 如何使用 AI 进行记录
  • set和map简单模拟实现
  • TCP 三次握手过程详解
  • 【Java学习笔记】抽象类
  • 时间的基本概念及相关技术
  • 通用寄存器 专用寄存器
  • 大模型训练中的GPU作用解析
  • 项目三 - 任务8:实现词频统计功能
  • 基于Geotools的Worldpop世界人口tif解析-以中国2020年数据为例
  • 北京大学肖臻老师《区块链技术与应用》公开课:02-BTC-密码学原理
  • Excel快捷键大全
  • 深入理解Java装饰器模式:动态扩展对象功能的优雅之道
  • USB设备状态
  • pyhton基础【5】循环
  • uniapp 小说成品源码
  • Python爬虫实战:研究Selenium框架相关技术
  • NAT、代理服务、内网穿透
  • Python训练营打卡Day37
  • 经典文献阅读之--RT-Grasp(通过MLLM进行推理调优的机器人抓取)
  • 如何设计ES的冷热数据分离架构?Elasticsearch 集群如何实现高可用?如何避免脑裂问题?如果出现脑裂如何恢复?
  • 6.1 Q1|广州医科大学GBD发文 | 良性前列腺增生与合并症之间的相关性
  • mysql ACID 原理
  • OpenCV CUDA模块图像过滤------创建一个 Sobel 滤波器函数createSobelFilter()
  • 高并发下使用防重表做防重案例
  • Linux 常用操作步骤
  • ubantu给github配置ssh
  • Unity—lua基础语法
  • MyBatis-Plus 中 的动态SQL 片段(sqlSegment)讲解
  • 速卖通,国际站测评补单,如何平衡效率和安全