ffmpeg操作摄像头

linux

ffmpeg -devices

1
2
3
4
5
6
7
8
9
10
11
12
13
Devices:
D. = Demuxing supported
.E = Muxing supported
--
DE alsa ALSA audio output
DE fbdev Linux framebuffer
D lavfi Libavfilter virtual input device
DE oss OSS (Open Sound System) playback
E sdl,sdl2 SDL2 output device
DE sndio sndio audio playback
DE video4linux2,v4l2 Video4Linux2 output device
D x11grab X11 screen capture, using XCB
E xv XV (XVideo) output device

ffmpeg -f v4l2 -list_formats all -i /dev/video0

1
2
[video4linux2,v4l2 @ 0x5588e89171c0] Compressed:       mjpeg :          Motion-JPEG : 1920x1080 352x288 432x240 320x184 176x144 160x120 320x240 640x360 640x480 800x600 960x720 1024x768 1280x720 1280x960
[video4linux2,v4l2 @ 0x5588e89171c0] Raw : yuyv422 : YUYV 4:2:2 : 1920x1080 352x288 432x240 320x184 176x144 160x120 320x240 640x360 640x480 800x600 960x720 1024x768 1280x720 1280x960

ffmpeg -f avfoundation -list_devices false -i “0”

ffmpeg -f avfoundation -list_devices true -i “”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
ffmpeg -f avfoundation -list_devices false -i "0"
ffmpeg version N-94324-g806ac7da69 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid --enable-libsrt --samples=fate-suite --pkg-config-flags=--static
libavutil 56. 30.100 / 56. 30.100
libavcodec 58. 53.101 / 58. 53.101
libavformat 58. 28.102 / 58. 28.102
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 56.101 / 7. 56.101
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[avfoundation @ 0x7fd691000a00] Selected framerate (29.970030) is not supported by the device.
[avfoundation @ 0x7fd691000a00] Supported modes:
[avfoundation @ 0x7fd691000a00] 160x120@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 160x120@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 160x120@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 160x120@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 160x120@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 160x120@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 160x120@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 176x144@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 176x144@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 176x144@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 176x144@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 176x144@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 176x144@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 176x144@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 320x180@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 320x180@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 320x180@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 320x180@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 320x180@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 320x180@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 320x180@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 320x240@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 320x240@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 320x240@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 320x240@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 320x240@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 320x240@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 320x240@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 352x288@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 352x288@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 352x288@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 352x288@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 352x288@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 352x288@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 352x288@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 424x240@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 424x240@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 424x240@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 424x240@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 424x240@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 424x240@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 424x240@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 480x270@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 480x270@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 480x270@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 480x270@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 480x270@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 480x270@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 480x270@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 640x480@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 640x480@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 640x480@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 640x480@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 640x480@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 640x480@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 640x480@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 800x448@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 800x448@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 800x448@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 800x448@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 800x448@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 800x448@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 800x448@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 848x480@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 848x480@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 848x480@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 848x480@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 848x480@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 848x480@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 848x480@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 800x600@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 800x600@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 800x600@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 800x600@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 800x600@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 800x600@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 800x600@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 960x540@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 960x540@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 960x540@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 960x540@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 960x540@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 960x540@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 960x540@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 1280x720@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 1280x720@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 1280x720@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 1280x720@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 1280x720@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 1280x720@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 1280x720@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 1600x896@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 1600x896@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 1600x896@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 1600x896@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 1600x896@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 1600x896@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 1600x896@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 1920x1080@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 1920x1080@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 1920x1080@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 1920x1080@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 1920x1080@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 1920x1080@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 1920x1080@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 160x120@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 160x120@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 160x120@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 160x120@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 160x120@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 160x120@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 160x120@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 176x144@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 176x144@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 176x144@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 176x144@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 176x144@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 176x144@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 176x144@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 320x180@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 320x180@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 320x180@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 320x180@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 320x180@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 320x180@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 320x180@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 320x240@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 320x240@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 320x240@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 320x240@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 320x240@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 320x240@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 320x240@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 352x288@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 352x288@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 352x288@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 352x288@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 352x288@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 352x288@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 352x288@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 424x240@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 424x240@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 424x240@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 424x240@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 424x240@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 424x240@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 424x240@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 480x270@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 480x270@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 480x270@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 480x270@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 480x270@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 480x270@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 480x270@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 640x480@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 640x480@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 640x480@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 640x480@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 640x480@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 640x480@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 640x480@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 800x448@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 800x448@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 800x448@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 800x448@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 800x448@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 800x448@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 800x448@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 848x480@[30.000030 30.000030]fps
[avfoundation @ 0x7fd691000a00] 848x480@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 848x480@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 848x480@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 848x480@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 848x480@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 848x480@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 800x600@[24.000038 24.000038]fps
[avfoundation @ 0x7fd691000a00] 800x600@[20.000000 20.000000]fps
[avfoundation @ 0x7fd691000a00] 800x600@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 800x600@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 800x600@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 800x600@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 960x540@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 960x540@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 960x540@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 960x540@[5.000000 5.000000]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[15.000015 15.000015]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[10.000000 10.000000]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[7.500002 7.500002]fps
[avfoundation @ 0x7fd691000a00] 1024x576@[5.000000 5.000000]fps
0: Input/output error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
root@cpx-System-Product-Name:/data/ffmpeg# ffmpeg -f v4l2 -list_formats all -i /dev/video0
ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/usr/local --enable-gpl --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libsrt --enable-libtheora --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-nonfree --samples=fate-suite --pkg-config-flags=--static
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
[video4linux2,v4l2 @ 0x55e5259941c0] Compressed: mjpeg : Motion-JPEG : 1920x1080 352x288 432x240 320x184 176x144 160x120 320x240 640x360 640x480 800x600 960x720 1024x768 1280x720 1280x960
[video4linux2,v4l2 @ 0x55e5259941c0] Raw : yuyv422 : YUYV 4:2:2 : 1920x1080 352x288 432x240 320x184 176x144 160x120 320x240 640x360 640x480 800x600 960x720 1024x768 1280x720 1280x960
/dev/video0: Immediate exit requested
root@cpx-System-Product-Name:/data/ffmpeg#