Video Collection process

1. Commands for querying basic information

2. Record commands

Ffmpeg-f avFoundation -i 1 -r 30 out.yuv -f: specifies where to collect data using avFoundation -i: specifies where to collect data from, which is a file index -r: specifies the frame rateCopy the code

2.1 Video Recording (Screen)

Recording video test:

2.1.1 Terminal Input Commands

ffmpeg -f avfoundation -i 1 -r 30 out.yuv
Copy the code

2.1.2 End Recording Command

Control + c Stops recordingCopy the code

2.1.3 After recording, play the recorded video

ffplay out.yuv
Copy the code

The following error occurs:

Because ffplay input is the original data, we do not know the size of each graph saved data, so we cannot render the display. So we need to give him a size.

We have a size parameter when recording:

Take this parameter and play the video

ffplay -s 2560-1600 out.yuv
Copy the code

But the video is garbled and unwatchable. This is because ffPlay is opened in yuV420P format and the video is recorded in UYVY422 format, so you need to specify the video recording format.

ffplay -s 2560-1600 -pix_fmt uyvy422 out.yuv
Copy the code

And that’s when we can see the video we just recorded

2.2 Recording Videos (Camera)

ffmpeg -f avfoundation -list_devices true -i ""
Copy the code

You can run the preceding command to view the devices supported by ACFoundation in the current MAC system

Video [0] represents the camera, video[1] represents the screen, and Autio [0] represents the built-in microphone

Video [0] represents the camera, video[1] represents the screen, and Autio [0] represents the built-in microphone.

Let’s start recording the video on the front page of the camera. Change the value of -i to 0:

ffmpeg -f avfoundation -i 0 -r 30 out.yuv
Copy the code

Selected Framerate (29.970030) is not supported by the device Selected Framerate (29.970030) is not supported by the device So we need to change the command:

ffmpeg -f avfoundation -video_size 640x480 -framerate 30 -i 0: -r 30 out1.yuv
Copy the code

After recording for a certain amount of time, end recording and open the previous video:

ffplay -s 640-480 -pix_fmt uyvy422 out1.yuv
Copy the code