1 综述

在使用FFMPEG 作为编码时,可以采用FFMPEG 采集本地的音视频设备的数据,然后进行编码,封装,传输等操作。 在不同的平台上,音视频数据采集驱动并不一致。 在linux 平台上有fbdex,v4l2,x11grab ,在ios 上有avfoundation. 在window 平台上有dshow,vfwcap.gdigrab。

Platform

Name

Describe

linux

fbdev

一个比较有年份的device,frameBuffer 专门用于图像的展示操作.在linux 平台下,我们可以通过如下命令去录屏:

./ffmpeg –framerate 30  –f  fbdev –i  /dev/fb0 output.mp4

linux

v4l2

linux平台下常见的视频设备 video4linux2,缩写为v4l2 ,可以通过如下命令去打开摄像头录像。

./ffmpeg –hide_banner –s 1920*1080  -i /dev/video0  output.avi

linux

x11grab

用去采集linux 桌面图像 x11grab

IOS

avfoundation

在IOS 平台下采集摄像头,麦克风,屏幕数据

Window

dshow

采集window 平台下摄像头,麦克风数据

Window

vfwcap

采集摄像头数据,这种方法已经过时了,现在用dshow 较多

Window

gdigrab

采集window 屏幕数据

2 使用流程

对于FFMPEG 来说,device 也是一个文件, 在使用device 进行录屏,摄像时, 与普通播放一个片源差不多。 就初始化处稍有点区别。

播放普通片源,初始化方式:

AVFormatContext *pFormatCtx = avformat_alloc_context();
avformat_open_input(&pFormatCtx, "test.h265",NULL,NULL);

而使用device 去录屏时:

AVFormatContext *pFormatCtx = avformat_alloc_context();
AVInputFormat *ifmt=av_find_input_format("vfwcap");
avformat_open_input(&pFormatCtx, 0, ifmt,NULL);

可以看出录屏与播放普通视频,就多一个av_find_input_forma() 的调用。

此处仅讲关于FFMPEG 有哪些API , 关于如何使用FFMPEG 操作device 录像,录屏请参考雷神csdn ,写的非常详细。

录像:https://blog.csdn.net/leixiaohua1020/article/details/39702113

录屏:https://blog.csdn.net/leixiaohua1020/article/details/39706721

3 AVDevice 相关API

如下是AVDevice 库开出的API , 很清晰, 比如查当前平台有哪些可用的device, 可用avdevice_list_devices()

函数名 作用
unsigned avdevice_version (void) 返回libavdevice_version_int常量
const char * avdevice_configuration (void) 返回libavdevice生成时配置。
const char * avdevice_license (void) 返回libavdevice许可证
void avdevice_register_all (void) 初始化libavdevice并注册所有输入和输出设备。
AVInputFormat * av_input_audio_device_next (AVInputFormat *d) 音频输入设备迭代器
AVInputFormat * av_input_video_device_next (AVInputFormat *d) 视频输入设备迭代器
AVOutputFormat * av_output_audio_device_next (AVOutputFormat *d) 音频输出设备迭代器
AVOutputFormat * av_output_video_device_next (AVOutputFormat *d) 视频输出设备迭代器
nt avdevice_app_to_dev_control_message (struct AVFormatContext *s, enum AVAppToDevMessageType type, void *data, size_t data_size) 从应用程序向设备发送控制消息
int avdevice_dev_to_app_control_message (struct AVFormatContext *s, enum AVDevToAppMessageType type, void *data, size_t data_size) 从设备向应用程序发送控制消息
int avdevice_capabilities_create (AVDeviceCapabilitiesQuery **caps, AVFormatContext *s, AVDictionary **device_options) 基于avoption api初始化功能探测api。
void avdevice_capabilities_free (AVDeviceCapabilitiesQuery **caps, AVFormatContext *s) 释放resources
int avdevice_list_devices (struct AVFormatContext *s, AVDeviceInfoList **device_list) 列出设备,返回可用户的device名字
void avdevice_free_list_devices (AVDeviceInfoList **device_list) 释放获得的device resource
int avdevice_list_input_sources (struct AVInputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list) 对adevice_list_devices() 一层封装
int avdevice_list_output_sinks (struct AVOutputFormat *device, const char *device_name, AVDictionary *device_options, AVDeviceInfoList **device_list)  

FFMPEG 之 AVDevice相关推荐

  1. 最简单的基于FFmpeg的AVDevice例子(屏幕录制)

    ===================================================== 最简单的基于FFmpeg的AVDevice例子文章列表: 最简单的基于FFmpeg的AVDe ...

  2. 最简单的基于FFmpeg的AVDevice例子(读取摄像头)

    ===================================================== 最简单的基于FFmpeg的AVDevice例子文章列表: 最简单的基于FFmpeg的AVDe ...

  3. 在iOS上使用ffmpeg播放视频

    国外靠谱的有这几个: 1.Mooncatventures grouphttps://github.com/mooncatventures-group 2.KxMoviePlayer (use Open ...

  4. FFMPEG学习(一)---【命令行】采集视频和音频

    FFMPEG常识 参数 参考:ffmpeg-比特率,帧率和文件大小 下载资源 下载ffmpeg安装包 加入环境变量: e:\ProgramFiles_D\ffmpeg\bin\ 输入设备 dshow ...

  5. ffmpeg ffplay ffprobe使用说明

    在CSDN上的这一段日子,接触到了很多同行业的人,尤其是使用FFMPEG进行视音频编解码的人,有的已经是有多年经验的"大神",有的是刚开始学习的初学者.在和大家探讨的过程中,我忽然 ...

  6. 详细介绍Qt,ffmpeg 和SDl 教程之间的联系

    Qt与 ffmpeg 与 SDl 教程是本文要介绍的内容,从多个角度介绍本文,运用了qmake,先来看内容. 1.  注释 从" #" 开始,到这一行结束. 2.  指定源文件 1 ...

  7. FFmpeg示例程序合集-批量编译脚本

    此前做了一系列有关FFmpeg的示例程序,组成了< 最简单的FFmpeg示例程序合集>,其中包含了如下项目: simplest ffmpeg player:                 ...

  8. [总结]FFMPEG视音频编解码零基础学习方法--转

    ffmpeg编解码学习 目录(?)[-] ffmpeg程序的使用ffmpegexeffplayexeffprobeexe 1 ffmpegexe 2 ffplayexe 3 ffprobeexe ff ...

  9. 从零开始学习音视频编程技术(七) FFMPEG Qt视频播放器之SDL的使用

    从零开始学习音视频编程技术(七) FFMPEG Qt视频播放器之SDL的使用 原文地址:http://blog.yundiantech.com/?log=blog&id=10 前面介绍了使用F ...

最新文章

  1. ActiveReports 报表应用教程 (1)-Hello ActiveReports
  2. C#设计模式(23种设计模式)
  3. sqlserver order by自定义数字排序 其他_苹果cms怎么自定义伪静态规则?
  4. PL/SQL控制结构
  5. java10个整数反向输出_输入一个整数,实现反转输出,如输入123,输出321。
  6. activemq概念介绍
  7. 学python看什么书-python有什么好的书籍
  8. 【MYSQL笔记】使用存储过程
  9. 转:awakeFromNib/loadView/viewDidLoad总结
  10. 一周第三次课(10月18日)
  11. 微信客服我是这样管理的
  12. 烽火狼烟丨PHP远程代码执行漏洞(CVE-2022-31625、CVE-2022-31626)风险提示
  13. 2019年末,10 位院士对 AI 的深度把脉(下)
  14. 【PCI】PCI驱动匹配(四)
  15. 数据结构与算法——深入理解红-黑树!
  16. 逻辑回归实战(动手实践)
  17. Q-learning原理及其实现方法
  18. 《烟花》个人深度解读
  19. 心理学转到计算机的女科学家,从局外人到局中人心理学研究理念演变.doc
  20. widget jquery 理解

热门文章

  1. 预编译安装Aspera的linux版本到centos系统
  2. laravel 使用 Intervention/image 进行图片处理
  3. python报错:Invalid parameter alpha for estimator Pipeline
  4. 弄清楚这里所说的解耦是什么意思。
  5. cluster-trace-v2018 阿里集群数据集中文简介
  6. 【Pygame实战】学英语,SO easy 最热门TOP3单词小游戏代码,记单词好轻松,游戏全程学单词,不仅有趣还是备考利器哦~(附完整代码)
  7. 2022年高处安装、维护、拆除考试资料及高处安装、维护、拆除操作证考试
  8. 几十所“双一流”大学公布应届生平均薪资!研究生能拿多少钱?
  9. VBA添加工作表详解
  10. DAC调用INFA命令