当前位置: 首页 > 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 设置超时等参数优化稳定性。

相关文章:

  • Anaconda 的基础教程,从入门到精通
  • FFMPEG-FLV-MUX编码
  • Flink流处理基础概论
  • springboot 微服务下部署AI服务
  • 微服务(SpringCloud)的简单介绍
  • 华为OD机试真题——传递悄悄话(二叉树最长路径问题)(2025A卷:200分)Java/python/JavaScript/C/C++/GO最佳实现
  • 深入研究Azure 容器网络接口 (CNI) overlay
  • 战略3.1 - 战略选择(发展战略-一体/密集/多元化)
  • 深度解析 8086 处理器:x86 架构的奠基者
  • RabbitMQ 核心原理与Spring Boot整合实战
  • 华为云Flexus+DeepSeek征文 | DeepSeek-V3/R1商用服务开通体验全流程及使用评测
  • 【Linux 学习计划】-- 进程概念与本质 | pid ppid | 进程创建与多进程(fork)
  • 黑龙江云前沿-服务器托管
  • 网络原理 | TCP与UDP协议的区别以及回显服务器的实现
  • 【邀请】点击邀请链接参加阿里云训练营活动,完成学习送礼品+鼠标垫+usb拓展坞,一个小时完成
  • Linux输出命令——echo解析
  • GitHub Page填写域名显示被占用
  • [服务器初体验] SSH登录成功后,我的新Linux服务器“空空如也”?三件必做的事让它安全又顺手
  • Go语言开发的GMQT物联网MQTT消息服务器(mqtt Broker)支持海量MQTT连接和快速低延时消息传输-提供源码可二次开发定制需求
  • 中小企业AI算力如何选?【显卡租赁】VS【自建服务器】
  • 网店美工主要负责什么工作/温州seo排名公司
  • 高端电子商务网站建设/关键词推广和定向推广
  • 68个偏门暴利项目/昆明seo工资
  • 免费装修效果图网站/浙江网站推广公司
  • java做网站的步骤/seo工具下载
  • 微网站如何做推广方案/百度做免费推广的步骤