当前位置:网站首页>Ffmpeg - sources analysis
Ffmpeg - sources analysis
2022-08-05 03:20:00 【hjjdebug】
ffmpeg -sources分析
----------------------------------------
author:hjjdebug
date: 2022年 08月 03日 星期三 16:42:27 CST
----------------------------------------
The output of the first to have a look at it:
$ ffmpeg -sources
Device name is not provided.
You can pass devicename[,opt1=val1[,opt2=val2...]] as an argument.
Auto-detected sources for alsa:
* default [Playback/recording through the PulseAudio sound server]
surround21 [2.1 Surround output to Front and Subwoofer speakers]
surround40 [4.0 Surround output to Front and Rear speakers]
surround41 [4.1 Surround output to Front, Rear and Subwoofer speakers]
surround50 [5.0 Surround output to Front, Center and Rear speakers]
surround51 [5.1 Surround output to Front, Center, Rear and Subwoofer speakers]
surround71 [7.1 Surround output to Front, Center, Side, Rear and Woofer speakers]
null [Discard all samples (playback) or generate zero samples (capture)]
samplerate [Rate Converter Plugin Using Samplerate Library]
speexrate [Rate Converter Plugin Using Speex Resampler]
jack [JACK Audio Connection Kit]
oss [Open Sound System]
pulse [PulseAudio Sound Server]
upmix [Plugin for channel upmix (4,6,8)]
vdownmix [Plugin for channel downmix (stereo) with a simple spacialization]
sysdefault:CARD=PCH [Default Audio Device]
front:CARD=PCH,DEV=0 [Front speakers]
dmix:CARD=PCH,DEV=0 [Direct sample mixing device]
dmix:CARD=PCH,DEV=2 [Direct sample mixing device]
dsnoop:CARD=PCH,DEV=0 [Direct sample snooping device]
dsnoop:CARD=PCH,DEV=2 [Direct sample snooping device]
hw:CARD=PCH,DEV=0 [Direct hardware device without any conversions]
hw:CARD=PCH,DEV=2 [Direct hardware device without any conversions]
plughw:CARD=PCH,DEV=0 [Hardware device with all software conversions]
plughw:CARD=PCH,DEV=2 [Hardware device with all software conversions]
usbstream:CARD=PCH [USB Stream Output]
usbstream:CARD=NVidia [USB Stream Output]
Auto-detected sources for oss:
Cannot list sources. Not implemented.
Auto-detected sources for sndio:
Cannot list sources. Not implemented.
Auto-detected sources for fbdev:
Could not open framebuffer device '/dev/fb0': Permission denied
Auto-detected sources for lavfi:
Cannot list sources. Not implemented.
Auto-detected sources for video4linux2,v4l2:
Auto-detected sources for x11grab:
Cannot list sources. Not implemented.
下面分析代码:
ffmpeg After analyzing options,调用了show_sources() 函数,关键代码如下:
fmt = 0;
do {
fmt = av_input_audio_device_next(fmt);
if (fmt) {
print_device_sources(fmt, opts);
}
} while (fmt);
do {
fmt = av_input_video_device_next(fmt);
if (fmt) {
print_device_sources(fmt, opts);
}
} while (fmt);
可见是2个循环.
First take a look at how to getfmt. ,由上一个format The next availableformat.
int i = 0;
while (prev && (fmt = indev_list[i])) {
i++;
if (prev == fmt) // fmt With an equal before stop.
break;
}
do {
fmt = indev_list[i++];
if (!fmt)
break;
category = pc->category;
} while (category != c1 && category != c2); //Find the next meets the requirements of,c1,c2是条件
return (AVInputFormat *)fmt;
The core is aindev_list[]数组, Search for:
static const AVInputFormat * const indev_list[] = {
&ff_alsa_demuxer,
&ff_fbdev_demuxer,
&ff_lavfi_demuxer,
&ff_oss_demuxer,
&ff_sndio_demuxer,
&ff_v4l2_demuxer,
&ff_xcbgrab_demuxer,
NULL };
这样我们就知道了,就这么多AVInputFormat. This is a harvest1
See below for eachAVInputFormat In the specific items and how to get?
This should see the followingprint函数, opts为NULL,fmt Is to get above
print_device_sources(fmt, opts);
fmt 的结构比较复杂,相当于一个类.
type = struct AVInputFormat {
const char *name;
const char *long_name;
int flags;
const char *extensions;
const struct AVCodecTag * const *codec_tag;
const AVClass *priv_class;
const char *mime_type;
struct AVInputFormat *next;
int raw_codec_id;
int priv_data_size;
int (*read_probe)(const AVProbeData *);
int (*read_header)(struct AVFormatContext *);
int (*read_packet)(struct AVFormatContext *, AVPacket *);
int (*read_close)(struct AVFormatContext *);
int (*read_seek)(struct AVFormatContext *, int, int64_t, int);
int64_t (*read_timestamp)(struct AVFormatContext *, int, int64_t *, int64_t);
int (*read_play)(struct AVFormatContext *);
int (*read_pause)(struct AVFormatContext *);
int (*read_seek2)(struct AVFormatContext *, int, int64_t, int64_t, int64_t, int);
int (*get_device_list)(struct AVFormatContext *, struct AVDeviceInfoList *);
int (*create_device_capabilities)(struct AVFormatContext *, struct AVDeviceCapabilitiesQuery *);
int (*free_device_capabilities)(struct AVFormatContext *, struct AVDeviceCapabilitiesQuery *);
}
But the other people all to write,就是上面7种,(Of course related to compile options,You can also add such asdecklink等设备)
Print two parts,Step is to obtain equipment,The second step is to print.
Access to equipment is the key,信息存入device_list
if ((ret = avdevice_list_input_sources(fmt, NULL, opts, &device_list)) < 0) {
printf("Cannot list sources.\n");
goto fail;
}
打印很简单,调用printfJust play.
for (i = 0; i < device_list->nb_devices; i++) {
printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
device_list->devices[i]->device_name, device_list->devices[i]->device_description);
}
device_list 需要讲一下,Because it is stored a lot of information.Data organization is harvest2
AVDeviceInfoList *device_list ;
typedef struct AVDeviceInfoList {
AVDeviceInfo **devices; /**< list of autodetected devices */
int nb_devices; /**< number of autodetected devices */
int default_device; /**< index of default device or -1 if no default */
} AVDeviceInfoList;
2Layer pointer is what?2Layer pointer is a pointer to the table,This form is a pointer table(A layer of pointer),2Pointer solution is a pointer of the quote.
You can also understand3Layer of a pointer is a pointer to a2Layer consisting of pointer table pointer.Reference solution is a2层指针.Of course there is no use,类推一下,Later it is used3层指针.
因为是一个AVDeviceInfo 列表,所以有一个nb_devices
AVDeviceInfo 是如下定义的,name,description
typedef struct AVDeviceInfo {
char *device_name; /**< device name, format depends on device */
char *device_description; /**< human friendly name */
} AVDeviceInfo;
Look at how to obtain equipment list below:
以 ff_alsa_demuxer,为利,Aside from some of its process,直接来到
return ff_alsa_get_device_list(device_list, SND_PCM_STREAM_CAPTURE); //获取CAPTURE 的列表
This function to get todevice 组织到device_list 中,主要流程如下:
if (snd_device_name_hint(-1, "pcm", &hints) < 0) //Get all the card informationhint
return AVERROR_EXTERNAL;
n = hints;
while (*n && !ret) {
name = snd_device_name_get_hint(*n, "NAME");
descr = snd_device_name_get_hint(*n, "DESC");
io = snd_device_name_get_hint(*n, "IOID");
if (!io || !strcmp(io, filter)) {
new_device = av_mallocz(sizeof(AVDeviceInfo)); // 分配内存
new_device->device_name = av_strdup(name);
new_device->device_description = av_strdup(descr);
if ((ret = av_dynarray_add_nofree(&device_list->devices, //加入数组
&device_list->nb_devices, new_device)) < 0) {
goto fail;
}
}
free(io);
free(name);
free(descr);
n++;
}
int snd_device_name_hint(int card, const char *iface, void ***hints);
card==-1, Get all the CARDShint, hints 是3层指针.
char *snd_device_name_get_hint(const void *hint, const char *id);
根据hint和id, Get the name of the corresponding.
These two functions, it is notffmpeg 函数,But the driver provides the function of the. The final data from driving,This is a harvest3
So the data analysis process is finished. 结束.
边栏推荐
- 2022 High-level installation, maintenance, and removal of exam questions mock exam question bank and online mock exam
- High Item 02 Information System Project Management Fundamentals
- 今年七夕,「情蔬」比礼物更有爱
- 人人都在说的数据中台,你需要关注的核心特点是什么?
- The linear table lookup
- How to transfer a single node of Youxuan database to a cluster
- Open-Falcon of operation and maintenance monitoring system
- ffmpeg pixel format basics
- 1667. Fix names in tables
- Burp installation and proxy settings
猜你喜欢
Principle and Technology of Virtual Memory
Never put off till tomorrow what you can put - house lease management system based on the SSM
[Filter tracking] based on matlab unscented Kalman filter inertial navigation + DVL combined navigation [including Matlab source code 2019]
Question about #sql shell#, how to solve it?
Matlab drawing 3
冰蝎V4.0攻击来袭,安全狗产品可全面检测
Talking about data security governance and privacy computing
Multithreading (2)
Step by step how to perform data risk assessment
Is your data safe in this hyperconnected world?
随机推荐
ffmpeg enumeration decoders, encoders analysis
Tencent Cloud [Hiflow] New Era Automation Tool
Matlab drawing 3
十五. 实战——mysql建库建表 字符集 和 排序规则
rpc-remote procedure call demo
MRTK3开发Hololens应用-手势拖拽、旋转 、缩放物体实现
队列题目:最近的请求次数
How Jin Cang database correctness verification platform installation file
为什么pca分量没有关联
Android实战开发-Kotlin教程(入门篇-登录功能实现 3.3)
leetcode-每日一题1403. 非递增顺序的最小子序列(贪心)
人人都在说的数据中台,你需要关注的核心特点是什么?
UOS系统下ksql应用缺少动态库”libtinfo.so.5“问题
A small tool to transfer files using QR code - QFileTrans 1.2.0.1
Details such as compiling pretreatment
Beyond YOLO5-Face | YOLO-FaceV2 officially open source Trick+ academic point full
Open Source License Description LGPL
Thinking (88): Use protobuf custom options for multi-version management of data
J9 Digital Currency: What is the creator economy of web3?
【 genius_platform software platform development 】 : seventy-six vs the preprocessor definitions written cow force!!!!!!!!!!(in the other groups conding personnel told so cow force configuration to can