How can record audio and video with ffmpeg at the same time?

I want to record with the hard device in my os:

lsusb | rg -i camera
Bus 001 Device 003: ID 2bdf:0284 SN0002 HIK 1080P CAMERA

It is a web-camera.

video can be recorded in my os with the ffmpeg command without audio:

ffmpeg -i /dev/video0 output.mkv 

audio can be recorded in my os with the ffmpeg command without video:

ffmpeg -f alsa  -i default  output.mp3

I want to record audio and video at the same time with ffmpeg:

ffmpeg -i /dev/video0 -f alsa -i default  output.mkv
ffmpeg -i /dev/video0 -f alsa -i default -c:v libx264 -c:a flac -r 30 output.mkv

All the command can record video without audio,why ffmpeg -f alsa -i default output.mp3 can recodr audio then?How can add the audio capture into ffmpeg with video capture?

Read more here: Source link