One, foreword

This series describes the ffmPEG command line support and use of -devices input and output devices.

  • Input Devices are used to collect/capture data from multimedia devices connected to the system, such as microphone/microphone audio sampling data, desktop screen image data, camera/camera image data, etc.

  • Output devices are used to write multimedia data to the output devices of the system, such as audio player devices, Windows, graphics rendering devices (openGL context, SDL), etc.

Ii. Reference materials

This article is from ffMPEG official documentation: ffmpeg.org/ffmpeg-devi…

How to download and install FFMPEG

  • Windows Platform download:

Ffmpeg.org/download.ht…

  • MAC Platform download:

Ffmpeg.org/download.ht…

  • Linux Platform download:

Linux distributions support ffMPEG. Ffmpeg provides two download links from ffmpeg.org/download.ht… And johnvansickle.com/ffmpeg/

How to view all input and output devices supported by FFMPEG

Use the ffmpeg command to list all devices supported by FFmpeg

ffmpeg.exe -devices

Note: The list of devices supported by FFMPEG depends on the system environment and device environment of each machine, and each machine may be different.

List of devices supported by FFMPEG

Input Devices

1. alsa

ALSA (Advanced Linux Sound Architecture) input device. To enable this input device during configuration, you need to have Libasound installed on your system. This device allows capture from an ALSA device. The name of the device to capture must be an ALSA card identifier.

Alsa details: www.alsa-project.org/alsa-doc/al…

1.1 ffmpeg command

ffmpeg -f alsa -i hw:0 alsaout.wav

1.2 Parameter Description

hw:CARD[,DEV[,SUBDEV]]

The three parameters are CARD, DEV, and SUBDEV in sequence.

  • CARD: Specifies the CARD number or identifier
  • DEV: indicates the device ID
  • SUBDEV: indicates the subdevice number (-1 indicates any number).

2. android_camera

Android camera input device.

Based on the Android Camera2 NDK API, which is available on devices with API level 24+. The availability of Android_camera is automatically detected during configuration.

The device allows capture from all cameras on Android devices integrated in the Camera2 NDK API. The available cameras are enumerated internally and can be selected using the camerA_index parameter. The input file string will be discarded. Typically, the rear camera has an index of 0 and the front camera has an index of 1.

3. avfoundation

AVFoundation is Apple’s current recommended multimedia framework for streaming image and audio capture on OSX> = 10.7 and iOS. You can use ffmpeg-f avfoundation-list_devices true -i “” to list the supported fetching device names and corresponding device index numbers on the current macOS or iOS.

3.1 ffmpeg command

Ffmpeg-f avfoundation -i “0:0” out.avi

Record the video device with index 0 and the audio device with index 0 into an out.avi video file

3.2 Parameter Description

-i “[[VIDEO] : [AUDIO]]”

Video: video device index audio: Audio device index Number Run the ffmpeg -f avfoundation-list_devices true -i “” command to query the index number.

4. bktr

BSD video input device.

5. decklink

The DeckLink input device provides capture capabilities for the Blackmagic DeckLink device.

6.dshow

Windows DirectShow input device used to collect video and audio devices in Windows. Run the ffmpeg-list_devices true -f dshow -i dummy command to view the list of supported devices, including device names and device types.

6.1 ffmpeg command

Ffmpeg-f dshow -I video= “Camera” :audio= “Microphone”

Turn on the camera and microphone

6.2 Parameter Description

TYPE=NAME[:TYPE=NAME]

  • TYPE: indicates the device TYPE, video or audio
  • NAME: device NAME (corresponding to device NAME output in ffmpeg-list_devices true -f dshow -i dummy)

7. fbdev

Linux frame buffer input device. Linux frame buffers are graphics abstraction layers independent of graphics hardware that are used to display graphics on computer monitors, usually on consoles. It is accessed through the file device node (typically /dev/fb0).

For details: linux-fbdev.sourceforge.net/

8.gdigrab

Win32 GDI based screen capture device. You can capture the screen image of the Windows desktop display area, including the Windows window display screen.

8.1 ffmpeg command

Capture the screen image of the specified area of the desktop screen (without -offset_x and -offset_y to capture the full screen)

ffmpeg -f gdigrab -framerate 6 -offset_x 10 -offset_y 20 -video_size vga -i desktop out.mpg

Captures the calculator window screen image

ffmpeg -f gdigrab -framerate 6 -i title=Calculator out.mpg

8.2 Parameter Description

Title = WINDOW_title: Window_title is the title of the Windows window, note that it is not the process name. Draw_mouse: whether to draw the mouse, 0: 1: draws the mouse (default: 1 if the mouse is empty). -offset_x: captures the X coordinate of the captured area. The upper left corner of the screen is the starting coordinate (0,0), and the lower right corner is (screenSize,screenSize)

9. iec61883

Use libiEC61883 FireWire DV/HDV input device.

10. jack

JACK input device

11. kmsgrab

KMS video input device. Captures the KMS scan output frame buffer associated with the specified CRTC or plane as a DRM object and passes it to other hardware functions. DRM master or CAP_SYS_ADMIN is required to run.

12. lavfi

Libavfilter Enter the virtual device. The input device reads data from the open output pad of the LibavFilter graph. For each output that the FilterGraph opens, the input device creates a corresponding stream that maps to the generated output. Currently, only video data is supported. The filter diagram is specified by the options diagram.

13. libcdio

Audio CD input device based on Libcdio. To enable this input device during configuration, you need to have Libcdio installed on your system. It requires the configuration option – enable-libcdio. This device allows playback and scraping from audio CDS.

14. libdc1394

IIDC1394 input device, based on libdc1394 and libraw1394.

15. openal

The OpenAL input device provides audio capture on all systems with an effective OpenAL 1.1 implementation. OpenAL headers and libraries should be provided as part of the OpenAL implementation or as another download (SDK).

16. oss

Turn on the sound system input device. The file name supplied to the input device is the device node representing the OSS input device, usually set to /dev/dsp.

17. pulse

PulseAudio input device. The file name supplied to the input device is the source device or the string “default”.

18. sndio

Sndio input devices. The file name supplied to the input device is the device node representing the SNdio input device, usually set to /dev/audio0.

19. video4linux2, v4l2

Video4Linux2 inputs video devices. “V4l2” can be used as an alias for “Video4Linux2”. If FFmpeg is built with v4l-utils support (by using the -enable-libv4l2 configuration option), it can be used with the -use_libv4l2 input device option. The name of the device to be captured is the file device node, which is typically created automatically by Linux when a device (such as a USB webcam) is inserted into the system, and is named /dev/videon, where N is the number associated with the device. Video4Linux2 devices typically support a limited set of widthxheight sizes and frame rates. You can use -list_Formats all to see what the Video4Linux2 device supports. Some devices, such as TV cards, support one or more standards. You can use -list_standards all to list all supported standards. The time base of the time stamp is 1 microsecond. Depending on the kernel version and configuration, the timestamp may come from a real-time clock (Unix era origin) or a monotonic clock (typically originating at boot time and not affected by NTP or manually changing the clock). The -timestamps ABS or -ts abs option can be used to force a real-time clock.

20. vfwcap

VfW (Windows Video) capture input devices. The file name passed as input is the capture driver number, which ranges from 0 to 9 and is generally used to capture camera images. You can use list as the file name to view the list of supported devices. Any other file name will be interpreted as device number 0.

2.1 ffmpeg command

View the list of supported devices

ffmpeg -y -f vfwcap -i list

Capture camera images and save them as mp4 files

ffmpeg -y -f vfwcap -i 0 out.mp4

20.2 Parameter Description

Video_size: set the size of the image to be captured (for example, 800×600). Framerate: framerate, default 30 frames

21. x11grab

X11 video input device. Can capture the X11 display area.

Output devices

1. alsa

ALSA (Advanced Linux Sound Architecture) output device.

2. AudioToolbox

AudioToolbox output equipment. Allows native output to CoreAudio devices on OSX.

3. caca

CACA output device. This output device allows the video stream to be displayed in the CACA window. Only one CACA window is allowed per application, so there can only be one instance of this output device in an application.

4. decklink

The DeckLink output device provides playback capabilities for Blackmagic DeckLink devices.

5. fbdev

Linux frame buffer output device. Linux frame buffers are graphics abstraction layers independent of graphics hardware that are used to display graphics on computer monitors, usually on consoles. It is accessed through the file device node (typically /dev/fb0). For more details about linux-fbdev.sourceforge.net/

6. opengl

OpenGL output device. This output device allows rendering to the OpenGL context. Context can be provided by the application or a default SDL window can be created.

7. oss

OSS (Open Sound System) output devices.

8. pulse

PulseAudio output device. For more information: www.pulseaudio.org.

9. sdl

SDL (Simple DirectMedia Layer) output device. Sdl2 can be used as an alias for SDL. This output device allows the video stream to be displayed in an SDL window. Only one SDL window is allowed per application, so there can only be one instance of this output device in an application. More information about SDL can be found at www.libsdl.org/

10. sndio

Sndio audio output device.

11. v4l2

Video4Linux2 output device.

12. xv

XV (XVideo) output device. Video streams can be displayed in the X Window System Window.